-
Notifications
You must be signed in to change notification settings - Fork 389
Fix false positive use of uninit bytes when calling libc::pthread_condattr_destroy
#1933
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
Conversation
Hm. Not sure why that's failing, seeing as 64 bit linux is the machine I'm testing on and |
d426269
to
eadeedd
Compare
Thanks for your first Miri PR! 🎉
Seems like you got that fixed? Our CI runs tests on the Linux host that use other OSes as target, so I assume that is what happened. |
Yeah, the 64 bit linux error was me not adding ignore-windows to the files, the error coming from linux and not windows confused me. No worries, got it fixed now in any case. Will fix the comments after work |
One... somewhat questionable thing we do is actually set the value of the Which would mean that simply having a destroyed pthread_mutex is UB, if you've not got it inside a MaybeUninit, and if we're assuming having an uninit variable as a local is instant UB. The standard library, at least for RWLock, doesn't keep the object inside a MaybeUninit, it's just an UnsafeCell. I guess the technically more correct thing to do here would be to have hidden state to keep track of which objects have been destroyed and which haven't, and trigger UB if you try to init an init object, or destroy an uninit object. And then just overwrite the object with arbitrary but still defined bytes(zeros, I suppose)? Not sure. The tests pass as is, but that is presumably miri just not checking "oh that thing that had uninit written to it is actually not in a MaybeUninit, that's instant UB!" |
So, can you use this to cause a UB error from the standard library? If |
Does being behind a reference mean you're not being used as your real type? I guess if you're going to be dropped, and you hold a &mut anyways, it's fine because no one else can see the uninit values, and it's fine to hold a In any case, I added a comment explaining it. |
LGTM aside from some comment tweaks. Can you also squash the last commit into the previous one? |
fe8281a
to
250d450
Compare
Co-authored-by: Ralf Jung <[email protected]>
Okay, applied the changes, and I'm happy with the way the comment reads. Also yeah, squashed the rustfmt commit. |
Great, thanks a lot! @bors r+ |
📌 Commit fd830e7 has been approved by |
☀️ Test successful - checks-actions |
Fixes: #1931