Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trait bounds for SharedMutex loose #2

Open
ammaraskar opened this issue Feb 24, 2021 · 0 comments
Open

Trait bounds for SharedMutex loose #2

ammaraskar opened this issue Feb 24, 2021 · 0 comments

Comments

@ammaraskar
Copy link

Hi there, we (Rust group @sslab-gatech) are scanning crates on crates.io for potential soundness bugs. We noticed that SharedMutex implements Send and Sync so long as the contained type is Sync:

unsafe impl<T: ?Sized + Send> Send for SharedMutex<T> {}
unsafe impl<T: ?Sized + Sync> Sync for SharedMutex<T> {}

However, this should be Send + Sync bound just like the standard library's Mutex requires Send. There are some types such as MutexGuard which are safe to use across threads but can't be sent (in the case of MutexGuard this is because it's undefined behavior to acquire and free a lock from a different thread). There's more examples here: https://users.rust-lang.org/t/sync-but-not-send/21551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant