How do you use Sentry?
Sentry SaaS (sentry.io)
SDK version
0.46.0
Steps to reproduce
let sg = HubSwitchGuard::new(Hub::current())
std::thread::spawn(move|| { let _ = sg; }
Expected result
Compilation error
Actual result
New thread gets its hub replaced by that of the parent thread, and parent thread never recovers their own hub.
Because HubSwitchGuard is about managing the thread-local that represents the current hub for this thread, it really doesn't make sense to move it to another thread, and as such that should be prevented. (HubSwitchGuard should be !Send)
This can be achieved with e.g. a field like this _make_type_not_send: std::marker::PhantomData<std::sync::MutexGuard<'static, ()>>,
How do you use Sentry?
Sentry SaaS (sentry.io)
SDK version
0.46.0
Steps to reproduce
let sg = HubSwitchGuard::new(Hub::current())std::thread::spawn(move|| { let _ = sg; }Expected result
Compilation error
Actual result
New thread gets its hub replaced by that of the parent thread, and parent thread never recovers their own hub.
Because
HubSwitchGuardis about managing the thread-local that represents the current hub for this thread, it really doesn't make sense to move it to another thread, and as such that should be prevented. (HubSwitchGuardshould be!Send)This can be achieved with e.g. a field like this
_make_type_not_send: std::marker::PhantomData<std::sync::MutexGuard<'static, ()>>,