-
Notifications
You must be signed in to change notification settings - Fork 359
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
False positive when warning about use of uninit plain bytes in std::sync::CondVar::new()
#1931
Comments
Relevant bit of code seems to be miri/src/shims/posix/foreign_items.rs Lines 334 to 343 in adc26a3
Looks fairly simple to implement, so I'll claim this. |
The man page says
Does this mean we should write uninit to the target of the pointer? (To protect against double That, and double init is... probably not okay? It says "Results are undefined if pthread_condattr_init() is called specifying an already initialized attr attributes object", but I'm not sure if I should take that to mean "it is UB to do that". |
Technically yes, but we aren't as thorough with this as we should be. Technically a mir::Operand::Move should also uninitialize the moved from place, but we don't. If it's not too much trouble and since the docs say so, go right ahead and overwrite with uninit |
Good catch! This regression was introduced with #1904, looks like our test suite does not cover enough of the Thanks for the report and fix. ❤️ |
Reproduction code:
Run with
MIRIFLAGS="-Zmiri-check-number-validity" cargo miri run
Error:
The relevant bit of stdlib code seems to be
where miri doesn't see that
pthread_condattr_init(attr.as_mut_ptr())
makespthread_condattr_destroy(attr.as_mut_ptr())
not UB.The text was updated successfully, but these errors were encountered: