Skip to content
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

Transmutes through usize do not preserve provenance, use AtomicPtr instead #1

Open
saethlin opened this issue Mar 9, 2024 · 2 comments

Comments

@saethlin
Copy link

saethlin commented Mar 9, 2024

It looks to me like this crate has copied a strategy from the standard library that I patched out of the standard library in rust-lang/rust#95621. Since Rust has Provenance this pattern causes this crate to execute UB.

I encountered this issue in a crater run for rust-lang/rust#121282.

@spearman
Copy link
Owner

spearman commented Mar 9, 2024

Thanks for reporting. Made an attempt here to use AtomicPtr 1cdde6b
but tests are failing with:

tcache_thread_shutdown(): unaligned tcache chunk detected

@saethlin
Copy link
Author

saethlin commented Mar 9, 2024

I suggest using Miri to work on code like this. Run these to install Miri:

rustup toolchain add nightly
rustup component add --toolchain=nightly miri

Then run your tests with Miri using cargo +nightly miri test.

When I do that on your branch, Miri reports a data race. I suspect that's the cause of the allocator corruption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants