-
Notifications
You must be signed in to change notification settings - Fork 355
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
Detect mixed-size and mixed-atomicity non-synchronized accesses #3137
Conversation
…if both are reads
@bors r=oli-obk |
Detect mixed-size and mixed-atomicity non-synchronized accesses Fixes #2303
@@ -267,7 +267,7 @@ fn concurrent_wait_wake() { | |||
FUTEX.store(FREE, Ordering::Relaxed); | |||
unsafe { | |||
DATA = 1; | |||
libc::syscall(libc::SYS_futex, &FUTEX as *const AtomicI32, libc::FUTEX_WAKE, 1); | |||
libc::syscall(libc::SYS_futex, addr_of!(FUTEX), libc::FUTEX_WAKE, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused about the changes to this file. Does this mean that creating a reference to an atomic type is considered a data race?
And if so, is Atomic*::as_ptr not safe as well?
(Or maybe the problem was only in the code creating references to non-atomic integers, and was done for code style consistency?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff you are commenting on was not necessary, interior mutability blocks the spurious reads.
But other parts of this test use static mut FUTEX: i32
, and &FUTEX
then induces a non-atomic read that was now causing problems. I figured I'd change everything to use addr_of!
consistently while I am at it.
(Or maybe the problem was only in the code creating references to non-atomic integers, and was done for code style consistency?)
Yes, that.
💔 Test failed - checks-actions |
@bors r=oli-obk |
☀️ Test successful - checks-actions |
Fixes #2303