Skip to content

Miri diagnostics: Show location of creation/invalidation in own code #2185

Open
@Noratrieb

Description

@Noratrieb

I'm in a crate (rustc_arena) where some UB was found. The created/invalidated spans point at core, since it's in the same workspace.

Backtrace

test tests::bench_copy ... error: Undefined Behavior: attempting a write access using <210850> at alloc86975[0x0], but that tag does not exist in the borrow stack for this location
    --> /home/nilsh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1342:9
     |
1342 |         copy_nonoverlapping(&src as *const T, dst, 1);
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |         |
     |         attempting a write access using <210850> at alloc86975[0x0], but that tag does not exist in the borrow stack for this location
     |         this error occurs as part of an access at alloc86975[0x0..0xc]
     |
     = 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: <210850> was created by a retag at offsets [0x0..0xffc]
    --> /home/nilsh/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/mod.rs:507:9
     |
507  |         self as *mut [T] as *mut T
     |         ^^^^
help: <210850> was later invalidated at offsets [0x0..0xffc]
    --> compiler/rustc_arena/src/lib.rs:90:48
     |
90   |         MaybeUninit::slice_as_mut_ptr(unsafe { &mut *self.storage.as_mut() })
     |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

It would be useful to be able to make it point to the actual offending calls in rustc_arena, since the actual bug was there.

See here: rust-lang/rust#97711

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-aliasingArea: This affects the aliasing model (Stacked/Tree Borrows)A-diagnosticserrors and warnings emitted by miriC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions