Hi!
We are a team of researchers studying the memory safety problem in Rust. As part of our ongoing research, we performed random testing on once_cell (version: 1.21.3) and found that the following code snippet is reported as deadlock by Miri:
#![feature(allocator_api)]
use once_cell::*;
fn main() {
let v15 = <sync::OnceCell::<bool> as std::default::Default>::default();
let v20 = sync::OnceCell::<bool>::wait(&v15);
}
I detected the deadlock using the command: MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-disable-stacked-borrows" cargo +nightly-2025-09-10 miri run.
Here is part of the error message:
error: the evaluated program deadlocked
--> /home/chenyl/.rustup/toolchains/nightly-2025-09-10-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/futex.rs:81:21
|
81 | )
| ^ this thread got stuck here
|
= note: BACKTRACE:
= note: inside `std::sys::pal::unix::futex::futex_wait` at /home/chenyl/.rustup/toolchains/nightly-2025-09-10-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/futex.rs:81:21: 81:22
= note: inside `std::sys::sync::thread_parking::futex::Parker::park` at /home/chenyl/.rustup/toolchains/nightly-2025-09-10-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/sync/thread_parking/futex.rs:55:13: 55:50
= note: inside `std::thread::Thread::park` at /home/chenyl/.rustup/toolchains/nightly-2025-09-10-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:1472:18: 1472:53
= note: inside `std::thread::park` at /home/chenyl/.rustup/toolchains/nightly-2025-09-10-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:1102:9: 1102:25
= note: inside `once_cell::imp::wait` at /home/chenyl/projects/Itgen_test/extra/once_cell-1.21.3/src/imp_std.rs:235:13: 235:27
= note: inside `once_cell::imp::initialize_or_wait` at /home/chenyl/projects/Itgen_test/extra/once_cell-1.21.3/src/imp_std.rs:202:17: 202:40
= note: inside `once_cell::imp::OnceCell::<bool>::wait` at /home/chenyl/projects/Itgen_test/extra/once_cell-1.21.3/src/imp_std.rs:89:9: 89:46
= note: inside `once_cell::sync::OnceCell::<bool>::wait` at /home/chenyl/projects/Itgen_test/extra/once_cell-1.21.3/src/lib.rs:995:17: 995:30
note: inside `main`
--> src/main.rs:5:15
|
5 | let v20 = sync::OnceCell::<bool>::wait(&v15);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error; 1 warning emitted
We’d appreciate it if you could take a look and confirm whether this behavior indicates a real issue, or if it’s a false positive or an expected limitation of Miri, or just because the inappropriate use of API.
Thank you very much for your time and for maintaining this great project! 🙏
Hi!
We are a team of researchers studying the memory safety problem in Rust. As part of our ongoing research, we performed random testing on once_cell (version: 1.21.3) and found that the following code snippet is reported as deadlock by Miri:
I detected the deadlock using the command: MIRIFLAGS="-Zmiri-ignore-leaks -Zmiri-disable-stacked-borrows" cargo +nightly-2025-09-10 miri run.
Here is part of the error message:
We’d appreciate it if you could take a look and confirm whether this behavior indicates a real issue, or if it’s a false positive or an expected limitation of Miri, or just because the inappropriate use of API.
Thank you very much for your time and for maintaining this great project! 🙏