-
Notifications
You must be signed in to change notification settings - Fork 7
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
Possible memory order issue #9
Comments
Same thing with a fence here: Line 162 in b72653f
It doesn't prevent writes to the underlying memory from moving before updating an atomic. It may be not noticed so far because x86-64 have a guaranteed store order but other platforms could do such moves. IMHO, you should use AcqRel fences in both cases. |
The code actually works, but it's a bit subtle. Essentially the |
But does volatile guarantee that CPU wouldn't reorder instructions? AFAIK, it only affects the compiler. |
Volatile on its own doesn't guarantee this, that's what the fence is for. |
Do I understand correctly that volatile read followed by a acquire fence hace same effect as acquire load, and therefore it would happen before any reads after fence? |
It's a bit of a gray area in the language, but it works in practice. The proper solution is to use something like rust-lang/rfcs#3301, but that doesn't exist in the language yet. |
Thank you for answering my questions. |
Hi!
I read a code of create and noticed this segment:
Shouldn't fence here use
AcqRel
? While using Acquire indeed prevents moving second atomic load up, it doesn't prevent moving read_volatile down. So CPU may reorder your code like this:The text was updated successfully, but these errors were encountered: