-
Notifications
You must be signed in to change notification settings - Fork 235
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
Soundness Bug - StreamContextInfo is not safe to send across threads #324
Comments
To clarify, from my point of understanding Arc is only We could just wrap it inside a Mutex, but AFAIK whether we use a Mutex or a |
Never mind, I just realized the core issue, guess it's a little bit late for me. Edit: See also this answer on SO about Drop requirements for why it's always both.. |
Reading over the code: Is there any reason to have this inside an Arc instead of a raw Box that is kept by StreamContextInfo for the callback ? We should have some guarantee about whether it's ok for the callback to a non-sync call or not. |
If we would simply expose a channel instead of a callback this could be completely eliminated. It would also allow #189. Though it's coming with its own limitations (and will introduce locking inside the callback). |
StreamContextInfo has I'm not familiar with #189, but the simplest solution for this would be to change StreamContextInfo's event_fn in |
Actually I'm wrong, RwLock is only |
In notify-rs#324, we found that we were passing StreamContextInfo to another thread, even though the type is not actually Send. Fixes notify-rs#324
We found another soundness issue. In src/fsevent.rs we have this definition:
This type is passed across a thread that actually listens to file changes. Unfortunately this type isn't actually send because while
pub trait EventFn: 'static + Fn(Result<Event>) + Send {}
implementsSend
,Arc<dyn EventFn>
is notSend
. That also requiresEventFn
to also implementSync
. Unfortunately just addingSync
doesn't compile because of some other conflicts.The text was updated successfully, but these errors were encountered: