vorner / arc-swap

Support atomic operations on Arc itself
Apache License 2.0
778 stars 31 forks source link

Support being run under miri #30

Closed vorner closed 4 years ago

vorner commented 4 years ago

It seems if some code that uses arc-swap is run on miri (even without threads), it makes miri angry.

2020-04-12T23:55:14.8305578Z error: unsupported operation: can't call foreign function: llvm.x86.sse2.pause
2020-04-12T23:55:14.8306231Z     --> /usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/../stdarch/crates/core_arch/src/x86/sse2.rs:25:5
2020-04-12T23:55:14.8306698Z      |
2020-04-12T23:55:14.8307145Z 25   |     pause()
2020-04-12T23:55:14.8307611Z      |     ^^^^^^^ can't call foreign function: llvm.x86.sse2.pause
2020-04-12T23:55:14.8307861Z      |
2020-04-12T23:55:14.8308072Z      = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
2020-04-12T23:55:14.8312403Z      = note: inside `std::arch::x86_64::_mm_pause` at /usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/../stdarch/crates/core_arch/src/x86/sse2.rs:25:5
2020-04-12T23:55:14.8313373Z      = note: inside `std::hint::spin_loop` at /usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/hint.rs:76:22
2020-04-12T23:55:14.8314364Z      = note: inside `std::sync::atomic::spin_loop_hint` at /usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/sync/atomic.rs:149:5
2020-04-12T23:55:14.8315561Z      = note: inside `arc_swap::ArcSwapAny::>::wait_for_readers` at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/arc-swap-0.4.5/src/lib.rs:1009:17
2020-04-12T23:55:14.8316314Z      = note: inside `> as std::ops::Drop>::drop` at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/arc-swap-0.4.5/src/lib.rs:700:9
2020-04-12T23:55:14.8317226Z      = note: inside `std::intrinsics::drop_in_place::>> - shim(Some(arc_swap::ArcSwapAny>))` at /usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ptr/mod.rs:177:1
2020-04-12T23:55:14.8317566Z note: inside `tests::arc_swap_` at lib.rs:1193:30
2020-04-12T23:55:14.8317941Z     --> lib.rs:1193:30
2020-04-12T23:55:14.8318137Z      |
2020-04-12T23:55:14.8318321Z 1193 |             let _ = x.clone();
2020-04-12T23:55:14.8318512Z      |                              ^
2020-04-12T23:55:14.8318694Z note: inside closure at lib.rs:1185:5
2020-04-12T23:55:14.8319026Z     --> lib.rs:1185:5
2020-04-12T23:55:14.8319225Z      |
2020-04-12T23:55:14.8319406Z 1185 | /     fn arc_swap_() {
2020-04-12T23:55:14.8319643Z 1186 | |         type ArcSwap = arc_swap::ArcSwapAny>;
2020-04-12T23:55:14.8319843Z 1187 | |
2020-04-12T23:55:14.8320059Z 1188 | |         let mut canary = atomic::AtomicUsize::new(0);
2020-04-12T23:55:14.8320236Z ...    |
2020-04-12T23:55:14.8320421Z 1195 | |         assert_eq!(canary.load(Acquire), 1);
2020-04-12T23:55:14.8320611Z 1196 | |     }
2020-04-12T23:55:14.8320788Z      | |_____^
2020-04-12T23:55:14.8321540Z      = note: inside `<[closure@lib.rs:1185:5: 1196:6] as std::ops::FnOnce<()>>::call_once - shim` at /usr/share/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:232:5

It would be nice to disable some things (if possible) to make it work.

Originaly reported by @zserik in #23.

vorner commented 4 years ago

@zserik Would you like to try this branch?