Skip to content

Instantly share code, notes, and snippets.

@jamesmunns
Created November 28, 2019 11:29
Show Gist options
  • Save jamesmunns/ad098b9eacedae389bfc605ff1f9d726 to your computer and use it in GitHub Desktop.
Save jamesmunns/ad098b9eacedae389bfc605ff1f9d726 to your computer and use it in GitHub Desktop.
git clone https://github.com/jamesmunns/bbqueue
cd bbqueue
james@archx1c6g ➜ bbqueue git:(miri-testing) git checkout miri-testing
Already on 'miri-testing'
james@archx1c6g ➜ bbqueue git:(miri-testing) cd bbqtest
james@archx1c6g ➜ bbqtest git:(miri-testing) cargo +master miri test --features travisci
Compiling bbqtest v0.1.0 (/home/james/stream2/bbqueue/bbqtest)
warning: unused import: `consts::*`
--> bbqtest/src/lib.rs:9:90
|
9 | use bbqueue::{consts::*, BBBuffer, ConstBBBuffer, Error as BBQError, GrantR, GrantW, consts::*, ArrayLength};
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: function is never used: `debug_grant_w`
--> bbqtest/src/lib.rs:54:8
|
54 | fn debug_grant_w<'a, N: ArrayLength<u8>>(data: &mut GrantW<'a, N>) {
| ^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: function is never used: `debug_grant_r`
--> bbqtest/src/lib.rs:63:8
|
63 | fn debug_grant_r<'a, N: ArrayLength<u8>>(data: &GrantR<'a, N>) {
| ^^^^^^^^^^^^^
running 5 tests
test single_thread::tests::sanity_check ... ok
test tests::deref_deref_mut ... ok
error: Miri evaluation error: trying to reborrow for Unique, but parent tag <371892> does not have an appropriate item in the borrow stack
--> /home/james/stream2/bbqueue/core/src/atomic.rs:594:9
|
594 | self.buf
| ^^^^^^^^ Miri evaluation error: trying to reborrow for Unique, but parent tag <371892> does not have an appropriate item in the borrow stack
|
note: inside call to `<bbqueue::atomic::GrantW<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B1>, typenum::bit::B0>> as std::ops::DerefMut>::deref_mut` at bbqtest/src/lib.rs:138:9
--> bbqtest/src/lib.rs:138:9
|
138 | x.copy_from_slice(&[11, 12]);
| ^
note: inside call to `tests::direct_usage_sanity` at bbqtest/src/lib.rs:73:5
--> bbqtest/src/lib.rs:73:5
|
73 | / fn direct_usage_sanity() {
74 | | // Initialize
75 | | let bb: BBBuffer<U6> = BBBuffer::new();
76 | | // bb.debug();
... |
218 | |
219 | | }
| |_____^
= note: inside call to closure at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libcore/ops/function.rs:223:5
= note: inside call to `<[closure@bbqtest/src/lib.rs:73:5: 219:6] as std::ops::FnOnce<()>>::call_once - shim` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libcore/ops/function.rs:223:5
= note: inside call to `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:542:5
= note: inside call to `tests::test::__rust_begin_short_backtrace::<fn()>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:533:30
= note: inside call to closure at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libcore/ops/function.rs:223:5
= note: inside call to `<[closure@DefId(17:635 ~ test[d4d4]::run_test[0]::{{closure}}[3]) 0:fn()] as std::ops::FnOnce<()>>::call_once - shim(vtable)` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/liballoc/boxed.rs:969:9
= note: inside call to `<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send> as std::ops::FnOnce<()>>::call_once` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panic.rs:316:9
= note: inside call to `<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>> as std::ops::FnOnce<()>>::call_once` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panicking.rs:289:40
= note: inside call to `std::panicking::try::do_call::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panicking.rs:284:5
= note: inside call to `std::panicking::try::<(), std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panic.rs:395:9
= note: inside call to `std::panic::catch_unwind::<std::panic::AssertUnwindSafe<std::boxed::Box<dyn std::ops::FnOnce() + std::marker::Send>>, ()>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:570:18
= note: inside call to `tests::test::run_test_in_process` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:473:21
= note: inside call to closure at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:494:13
= note: inside call to `tests::test::run_test::run_test_inner` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:530:28
= note: inside call to `tests::test::run_test` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:299:13
= note: inside call to `tests::test::run_tests::<[closure@DefId(17:427 ~ test[d4d4]::console[0]::run_tests_console[0]::{{closure}}[2]) 0:&mut tests::test::console::ConsoleTestState, 1:&mut std::boxed::Box<dyn tests::test::formatters::OutputFormatter>]>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/console.rs:295:5
= note: inside call to `tests::test::run_tests_console` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:120:15
= note: inside call to `tests::test::test_main` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libtest/lib.rs:139:5
= note: inside call to `tests::test::test_main_static`
= note: inside call to `main` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/rt.rs:61:34
= note: inside call to closure at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/rt.rs:48:73
= note: inside call to closure at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:136:5
= note: inside call to `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6021 ~ std[78b8]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/rt.rs:48:13
= note: inside call to closure at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panicking.rs:289:40
= note: inside call to `std::panicking::try::do_call::<[closure@DefId(1:6020 ~ std[78b8]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panicking.rs:284:5
= note: inside call to `std::panicking::try::<i32, [closure@DefId(1:6020 ~ std[78b8]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/panic.rs:395:9
= note: inside call to `std::panic::catch_unwind::<[closure@DefId(1:6020 ~ std[78b8]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/rt.rs:47:25
= note: inside call to `std::rt::lang_start_internal` at /home/james/.rustup/toolchains/master/lib/rustlib/src/rust/src/libstd/rt.rs:61:5
= note: inside call to `std::rt::lang_start::<()>`
error: aborting due to previous error
test tests::direct_usage_sanity ...
error: could not compile `bbqtest`.
To learn more, run the command again with --verbose.
james@archx1c6g ➜ bbqtest git:(miri-testing)
@oli-obk
Copy link

oli-obk commented Nov 28, 2019

🎉 you were right, there are multiple locations where borrows are invalidated

error: Miri evaluation error: disabling id 2144
   --> /home/oliver/Projects/rust/bbqueue/core/src/atomic.rs:388:26
    |
388 |         let c = unsafe { (*inner.buf.get()).as_ptr().cast::<u8>() };
    |                          ^^^^^^^^^^^^^^^^^^ Miri evaluation error: disabling id 2144
    |
note: inside call to `bbqueue::atomic::Consumer::<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UInt<typenum::uint::UTerm, typenum::bit::B1>, typenum::bit::B1>, typenum::bit::B0>>::read` at miri-repro/src/main.rs:123:17
   --> miri-repro/src/main.rs:123:17
    |
123 |         let r = cons.read().unwrap();
    |                 ^^^^^^^^^^^
note: inside call to `direct_usage_sanity` at miri-repro/src/main.rs:230:5
   --> miri-repro/src/main.rs:230:5
    |
230 |     direct_usage_sanity();
    |     ^^^^^^^^^^^^^^^^^^^^^
    = note: inside call to `main` at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:61:34
    = note: inside call to closure at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:48:73
    = note: inside call to closure at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/sys_common/backtrace.rs:136:5
    = note: inside call to `std::sys_common::backtrace::__rust_begin_short_backtrace::<[closure@DefId(1:6021 ~ std[4be1]::rt[0]::lang_start_internal[0]::{{closure}}[0]::{{closure}}[0]) 0:&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:48:13
    = note: inside call to closure at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:289:40
    = note: inside call to `std::panicking::try::do_call::<[closure@DefId(1:6020 ~ std[4be1]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:284:5
    = note: inside call to `std::panicking::try::<i32, [closure@DefId(1:6020 ~ std[4be1]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe]>` at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:395:9
    = note: inside call to `std::panic::catch_unwind::<[closure@DefId(1:6020 ~ std[4be1]::rt[0]::lang_start_internal[0]::{{closure}}[0]) 0:&&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe], i32>` at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:47:25
    = note: inside call to `std::rt::lang_start_internal` at /home/oliver/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:61:5
    = note: inside call to `std::rt::lang_start::<()>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment