Skip to content

Backtrace initial spans are missing if the topmost span is nonlocal? #2172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
saethlin opened this issue May 31, 2022 · 3 comments · Fixed by #2173
Closed

Backtrace initial spans are missing if the topmost span is nonlocal? #2172

saethlin opened this issue May 31, 2022 · 3 comments · Fixed by #2173

Comments

@saethlin
Copy link
Member

I just noticed that a lot of diagnostics are missing the topmost span, and I'm pretty sure it's related to whether the span is in a local crate.

For example, with raw pointer tagging on smallvec 1.8.0, we currently get:

test tests::drain ... error: Undefined Behavior: trying to reborrow <293683> for SharedReadOnly permission at alloc111484[0x9], but that tag does not exist in the borrow stack for this location
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the 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: <293683> was created by a retag at offsets [0x9..0xa]
   --> src/lib.rs:821:23
    |
821 |                 iter: range_slice.iter(),
    |                       ^^^^^^^^^^^^^^^^^^
help: <293683> was later invalidated at offsets [0x0..0x20]
   --> src/lib.rs:822:36
    |
822 |                 vec: NonNull::from(self),
    |                                    ^^^^

But crossbeam-epoch 0.9.8 with raw pointer tagging reports this:

test atomic::tests::array_init ... error: Undefined Behavior: trying to reborrow <untagged> for SharedReadOnly permission at alloc94974[0x0], but that tag does not exist in the borrow stack for this location
    --> src/atomic.rs:264:21
     |
264  |         let array = &*(ptr as *const Array<T>);
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
     |                     |
     |                     trying to reborrow <untagged> for SharedReadOnly permission at alloc94974[0x0], but that tag does not exist in the borrow stack for this location
     |                     this error occurs as part of a reborrow at alloc94974[0x0..0x8]
     |
     = help: this indicates a potential bug in the program: it performed an invalid operation, but the 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

I feel like we should be able to test for this regression?

@RalfJung
Copy link
Member

We always print the topmost span of the backtrace:

let span = stacktrace.first().map_or(DUMMY_SP, |fi| fi.span);

To me this looks more like stdlib span printing is broken.

@RalfJung
Copy link
Member

I see the same thing with ./miri run tests/compile-fail/intrinsics/out_of_bounds_ptr_3.rs. I am pretty sure this used to work.

My guess is that this has to do with the -Zremap-cwd-prefix=rustc_src that @oli-obk recently added to the flags that we build our stdlib with.

@RalfJung
Copy link
Member

My guess is that this has to do with the -Zremap-cwd-prefix=rustc_src that @oli-obk recently added to the flags that we build our stdlib with.

Guess confirmed, after removing that flag I get the expected

error: Undefined Behavior: pointer arithmetic failed: alloc1655 has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
   --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ptr/const_ptr.rs:455:18
    |
455 |         unsafe { intrinsics::offset(self, count) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer arithmetic failed: alloc1655 has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
    |
    = 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: inside `std::ptr::const_ptr::<impl *const i8>::offset` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ptr/const_ptr.rs:455:18
note: inside `main` at tests/compile-fail/intrinsics/out_of_bounds_ptr_3.rs:5:22
   --> tests/compile-fail/intrinsics/out_of_bounds_ptr_3.rs:5:22
    |
5   |     let x = unsafe { x.offset(-1) };
    |                      ^^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants