You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[walter@cuddles generic_singleton_user]$ cargo miri run
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `/home/walter/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/generic_singleton_user`
1
error: Undefined Behavior: Data race detected between Read on thread `<unnamed>` and Write on thread `<unnamed>` at alloc3852
--> /home/walter/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cell.rs:452:18
|
452 | unsafe { *self.value.get() }
| ^^^^^^^^^^^^^^^^^ Data race detected between Read on thread `<unnamed>` and Write on thread `<unnamed>` at alloc3852
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::cell::Cell::<isize>::get` at /home/walter/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cell.rs:452:18
= note: inside `std::cell::BorrowRefMut::<'_>::new` at /home/walter/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cell.rs:1682:15
= note: inside `std::cell::RefCell::<i32>::try_borrow_mut` at /home/walter/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cell.rs:987:15
note: inside `generic_call_counter::<i32>` at src/main.rs:6:21
--> src/main.rs:6:21
|
6 | let mut count = generic_singleton::get_or_init!(|| RefCell::new(T::zero())).borrow_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/main.rs:15:28
--> src/main.rs:15:28
|
15 | println!("{}", generic_call_counter::<i32>())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to previous error
The bug makes sense. Not sure why generic_singleton allows this usage :/
The text was updated successfully, but these errors were encountered:
The following code results in a bug from miri:
BUG:
The bug makes sense. Not sure why
generic_singleton
allows this usage :/The text was updated successfully, but these errors were encountered: