Miri test failure: Stacked Borrow rules violated
phil-opp opened this issue · 1 comments
phil-opp commented
Our scheduled CI jobs discovered a new set of Miri errors on the latest nightlies. The full logs are:
running 26 tests
error: Undefined Behavior: trying to retag from <202439> for SharedReadOnly permission at alloc86155[0x0], but that tag does not exist in the borrow stack for this location
--> /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/non_null.rs:385:18
|
385 | unsafe { &*self.as_ptr() }
| ^^^^^^^^^^^^^^^
| |
| trying to retag from <202439> for SharedReadOnly permission at alloc86155[0x0], but that tag does not exist in the borrow stack for this location
| this error occurs as part of retag at alloc86155[0x0..0x10]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <202439> was created by a SharedReadWrite retag at offsets [0x0..0x3e8]
--> src/test.rs:49:35
|
49 | let heap = unsafe { Heap::new(data.as_mut_ptr().cast(), data.len()) };
| ^^^^^^^^^^^^^^^^^
help: <202439> was later invalidated at offsets [0x0..0x400] by a Unique retag
--> src/test.rs:53:16
|
53 | let drop = move || {
| ________________^
54 | | let _ = heap_space;
55 | | };
| |_____^
= note: BACKTRACE:
= note: inside `core::ptr::NonNull::<hole::Hole>::as_ref::<'_>` at /home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/non_null.rs:385:18
note: inside `hole::Cursor::current` at src/hole.rs:50:18
--> src/hole.rs:50:18
|
50 | unsafe { self.hole.as_ref() }
| ^^^^^^^^^^^^^^^^^^
note: inside `hole::Cursor::split_current` at src/hole.rs:69:29
--> src/hole.rs:69:29
|
69 | let hole_size = self.current().size;
| ^^^^^^^^^^^^^^
note: inside `hole::HoleList::allocate_first_fit` at src/hole.rs:411:19
--> src/hole.rs:411:19
|
411 | match cursor.split_current(aligned_layout) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `Heap::allocate_first_fit` at src/lib.rs:196:15
--> src/lib.rs:196:15
|
196 | match self.holes.allocate_first_fit(layout) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside `hole::test::aff` at src/hole.rs:723:17
--> src/hole.rs:723:17
|
723 | let _ = heap.allocate_first_fit(reqd).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure at src/hole.rs:720:14
--> src/hole.rs:720:14
|
719 | #[test]
| ------- in this procedural macro expansion
720 | fn aff() {
| ^
= note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
cc @jamesmunns
jamesmunns commented
Thanks for tagging me!
I'll look into these today and report back :)