-
Notifications
You must be signed in to change notification settings - Fork 185
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
Weak Bindings Violate Strict Provenance in MIRI #262
Comments
@nvzqz I notice that the |
Yes, function pointers are tracked under strict provenance. The issue is that integers lose pointer provenance information. This same thing happened with libstd: rust-lang/rust#96167. |
Awesome, I'll take a look! |
Would you also need a 0.1 backport? |
I myself do not need this fixed in 0.1. This came up due to using |
This allows Strict Provenance to work properly, fixing #262. It also now matches what `libstd` does: https://github.com/rust-lang/rust/blob/9f7e997c8bc3cacd2ab4eb75e63cb5fa9279c7b0/library/std/src/sys/unix/weak.rs#L85-L141 Also, while reading the `libstd` code, I noticed that they use an `Acquire` fence and `Release` store as the returned pointer should have "consume" semantics. I changed our code to do something slightly stronger (Acquire load and Release store) for consistancy. Signed-off-by: Joe Richey <[email protected]>
This allows Strict Provenance to work properly, fixing #262. It also now matches what `libstd` does: https://github.com/rust-lang/rust/blob/9f7e997c8bc3cacd2ab4eb75e63cb5fa9279c7b0/library/std/src/sys/unix/weak.rs#L85-L141 Also, while reading the `libstd` code, I noticed that they use an `Acquire` fence and `Release` store as the returned pointer should have "consume" semantics. I changed our code to do something slightly stronger (Acquire load and Release store) for consistancy. Signed-off-by: Joe Richey <[email protected]>
This allows Strict Provenance to work properly, fixing #262. It also now matches what `libstd` does: https://github.com/rust-lang/rust/blob/9f7e997c8bc3cacd2ab4eb75e63cb5fa9279c7b0/library/std/src/sys/unix/weak.rs#L85-L141 Also, while reading the `libstd` code, I noticed that they use an `Acquire` fence and `Release` store as the returned pointer should have "consume" semantics. I changed our code to do something slightly stronger (Acquire load and Release store) for consistancy. Signed-off-by: Joe Richey <[email protected]>
It looks like we will have to use |
My understanding is that's totally fine. Considering that |
This allows Strict Provenance to work properly, fixing #262. It also now matches what `libstd` does: https://github.com/rust-lang/rust/blob/9f7e997c8bc3cacd2ab4eb75e63cb5fa9279c7b0/library/std/src/sys/unix/weak.rs#L85-L141 Also, while reading the `libstd` code, I noticed that they use an `Acquire` fence and `Release` store as the returned pointer should have "consume" semantics. As this doesn't yet exist in Rust, we instead do exactly what `libstd` does, which means: - Relaxed Load - Release Store - Acquire fence when returning pointer Signed-off-by: Joe Richey <[email protected]> Co-authored-by: Joe ST <[email protected]>
Because the
Weak
struct is defined as havingLazyUsize
for the address, it does not maintain pointer provenance and thus fails when run under MIRI with-Zmiri-strict-provenance
.The solution would be to define a
LazyPtr
type that utilizesAtomicPtr
instead ofAtomicUsize
.The text was updated successfully, but these errors were encountered: