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

Send/Sync impls are unsafe #26

Closed
Storyyeller opened this issue Mar 5, 2017 · 4 comments
Closed

Send/Sync impls are unsafe #26

Storyyeller opened this issue Mar 5, 2017 · 4 comments

Comments

@Storyyeller
Copy link
Contributor

I believe the following impls are unsafe

unsafe impl<O: Send, T: ?Sized> Send for OwningRef<O, T> {}
unsafe impl<O: Sync, T: ?Sized> Sync for OwningRef<O, T> {}
unsafe impl<O: Send, T: ?Sized> Send for OwningRefMut<O, T> {}
unsafe impl<O: Sync, T: ?Sized> Sync for OwningRefMut<O, T> {}

You need to check not only O, but also &T/&mut T. For example, if T is a Cell, this would improperly implement Sync. This can happen either if O contains a mutex that you map() into, or you map() into an unrelated 'static reference.

@Kimundi
Copy link
Owner

Kimundi commented Mar 5, 2017

I think you are right - I'll add the necessary constraints and see what happens.

@Kimundi
Copy link
Owner

Kimundi commented Mar 5, 2017

I pushed a new version, feel free to close this if the new impls look right to you.

@Storyyeller
Copy link
Contributor Author

Storyyeller commented Mar 5, 2017

Looks good to me. Thanks for the speedy fix!

@Storyyeller
Copy link
Contributor Author

P.S. You may want to consider yanking the previous versions if you haven't done so already to reduce the risk that people accidentally depend on them.

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

2 participants