-
Notifications
You must be signed in to change notification settings - Fork 31
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
Undefined behaviour inside library #2
Comments
#3 Another UB. Analyzed by hand |
SyncSignal is const reference now. if you think it's fixed feel free to close the thread. |
That part is fixed, I've also added a PR that fixes some other sync related issues: #4 I'll do async separetely since it it's harder to grok through miri's error messages there. |
Do you have any examples? I just pulled the latest commit and all I see is a straightforward aliasing issue. |
There is no known undefined behavior in the library anymore, Miri reports no error on both sync and async, feel free to reopen the issue if you found something new. |
miri reports lots undefined behaviour, and some are easy to confirm.
For example
Which is easy to confirm:
One thread has a
Send
which will lock anInternal
which will then try to register (sometimes) aSyncSignal
which will push a *mut SyncSignal in a list.Thread 1 still has a mutable live access to this
SyncSignal
(let's name itsig
). From it's point of view no one else can modify it, or it's inner fields, even creating a &mut for this same object is undefined behaviour in rust. This also is valid for it's State field which has an atomic. Having a &mut reference (even to an atomic) guarantees to the compiler that the memory pointed to can not be changed by anyone.Thread 2 (the receiver) will pop this *mut SyncSignal from the list and dereference the pointer to call recv on it (that dereference will already introduce undefined behaviour by virtue of having 2 &mut references to
sig
from 2 threads at the same time).You might argue that rust rules are too restrictive, but you also end up doing a write while these 2 mutable references are live. The first thread (sender), while waiting will write it's state with self.state.upgrade_lock() effectively introducing a race condition.
The text was updated successfully, but these errors were encountered: