Skip to content

HubSwitchGuard should not be Send #943

@Ten0

Description

@Ten0

How do you use Sentry?

Sentry SaaS (sentry.io)

SDK version

0.46.0

Steps to reproduce

  1. let sg = HubSwitchGuard::new(Hub::current())
  2. 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, ()>>,

Metadata

Metadata

Labels

BugSomething isn't workingRustSDK

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions