Closed
Description
Today's run of the std test suite in Miri failed on macOS:
3.314536 test sync::rwlock::tests::frob ... error: Undefined Behavior: trying to retag from <42368726> for SharedReadOnly permission at alloc9742021[0x0], but that tag does not exist in the borrow stack for this location
0.000053 --> /home/runner/work/miri-test-libstd/miri-test-libstd/rust-src-patched/library/core/src/ptr/non_null.rs:401:18
0.000015 |
0.000009 401 | unsafe { &*self.as_ptr().cast_const() }
0.000010 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.000009 | |
0.000010 | trying to retag from <42368726> for SharedReadOnly permission at alloc9742021[0x0], but that tag does not exist in the borrow stack for this location
0.000008 | this error occurs as part of retag at alloc9742021[0x0..0x30]
0.000009 |
0.000009 = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
0.000009 = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
0.000010 help: <42368726> was created by a SharedReadOnly retag at offsets [0x0..0x8]
0.000009 --> std_miri_test/../library/std/src/sys/locks/rwlock/queue.rs:348:32
0.000009 |
0.000009 348 | let mut next = ptr::from_ref(&node)
0.000009 | ^^^^^^^^^^^^^^^^^^^^
0.000011 help: <42368726> was later invalidated at offsets [0x8..0x10] by a write access
0.000010 --> std_miri_test/../library/std/src/sys/locks/rwlock/queue.rs:347:17
0.000008 |
0.000009 347 | node.prev = AtomicLink::new(None);
0.000009 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.000009 = note: BACKTRACE (of the first span):
0.000009 = note: inside `core::ptr::NonNull::<sys::locks::rwlock::queue::Node>::as_ref::<'_>` at /home/runner/work/miri-test-libstd/miri-test-libstd/rust-src-patched/library/core/src/ptr/non_null.rs:401:18: 401:46
0.000009 note: inside `sys::locks::rwlock::queue::add_backlinks_and_find_tail`
0.000009 --> std_miri_test/../library/std/src/sys/locks/rwlock/queue.rs:265:17
0.000009 |
0.000009 265 | next.as_ref().prev.set(Some(current));
0.000009 | ^^^^^^^^^^^^^
0.000008 note: inside `sys::locks::rwlock::queue::RwLock::unlock_queue`
0.000009 --> std_miri_test/../library/std/src/sys/locks/rwlock/queue.rs:487:33
0.000009 |
0.000008 487 | let tail = unsafe { add_backlinks_and_find_tail(to_node(state)) };
0.000009 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0.000009 note: inside `sys::locks::rwlock::queue::RwLock::lock_contended`
0.000009 --> std_miri_test/../library/std/src/sys/locks/rwlock/queue.rs:383:25
0.000009 |
0.000008 383 | self.unlock_queue(next);
0.000009 | ^^^^^^^^^^^^^^^^^^^^^^^
0.000009 note: inside `sys::locks::rwlock::queue::RwLock::write`
0.000010 --> std_miri_test/../library/std/src/sys/locks/rwlock/queue.rs:312:13
0.000009 |
0.000009 312 | self.lock_contended(true)
0.000009 | ^^^^^^^^^^^^^^^^^^^^^^^^^
0.000009 note: inside `sync::rwlock::RwLock::<()>::write`
0.000009 --> std_miri_test/../library/std/src/sync/rwlock.rs:361:13
0.000009 |
0.000009 361 | self.inner.write();
0.000009 | ^^^^^^^^^^^^^^^^^^
0.000010 note: inside closure
0.000011 --> std_miri_test/../library/std/src/sync/rwlock/tests.rs:37:26
0.000009 |
0.000010 37 | drop(r.write().unwrap());
0.000008 | ^^^^^^^^^
The diff to the last successful run is this, but since this is a concurrency test, there's a high chance that the bug already existed before and only surfaces randomly. So #110211 is the most likely culprit.
So far I haven't managed to reproduce this outside the context of the standard library test suite.