-
Notifications
You must be signed in to change notification settings - Fork 343
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
Miri accepts an open-coded compare-exchange loop but rejects the equivalent code using fetch_update #3613
Comments
Yes the closure adds additional requirements. The problem here is field retagging. If you set I think the problem here is that the closure captures a |
As an side, our handling of tags that refer to arguments seems to fall apart when the call is a closure. |
So -- the hypothesis is that after the CAS succeeds but before That sounds plausible. The easiest work-around then is to make last_next a raw pointer. Currently it is a reference and the lifetime of that reference is just a bit too long for this code to be sound. |
Thank you both for looking into this!
Indeed, using a raw pointer and a short lived reference only inside the closure like adamreichold/lockfree-collector@9fd7738 does resolve the issue https://github.com/adamreichold/lockfree-collector/actions/runs/9148024927/job/25150080367 So if I understand you correctly, there is no bug here and maybe a bit of a sharp edge when using I think for the collector, I'll stick to the open-coded loop as |
Thanks for trying that!
Yeah, Miri is working as intended, so I will close the issue. There's a t-opsem question here whether maybe closure fields should be wrapped in |
I have a little1 lock-free data structure I would like to use in PyO3 and I tested it using Miri (with the default settings) to increase my confidence that it actually works.
One thing I found during testing is that replacing an open-coded compare-exchange loop by the equivalent code using
fetch_update
inadamreichold/lockfree-collector@2044350
is rejected by Miri, c.f.
https://github.com/adamreichold/lockfree-collector/actions/runs/9141771033/job/25136576921
Is it possible the closure used by
fetch_update
confuses Miri or does it indeed add additional requirements that the unsafe code violates? Or did I make a mistake and the code is not in fact equivalent?Footnotes
famous last words ↩
The text was updated successfully, but these errors were encountered: