-
Notifications
You must be signed in to change notification settings - Fork 372
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
Unhelphful stacked borrows diagnostic span #2536
Comments
Are you saying there already is UB earlier in the program, before line 152 is reached?
Ah, that's very different from "incorrect". :) Could you elaborate a bit more why you think that other span is more relevant than the one where 3540 is created and invalidated, and what lines 123 and 126 even have to do with tag 3540? |
Lines 123 and 126 call Since the pointer was derived from an Replacing the |
This is an order of operations issue. We find the project-local current span, then consider if the retag we're executing is a FnEntry and reach up to the parent for a span in the caller. But in this case, we are already in the caller because the span of the FnEntry retag is in I'll cook up a little test for this, and I think just adding a |
Don't back up past the caller when looking for an FnEntry span Fixes rust-lang/miri#2536 This adds a fix for the logic as well as a regression test. In the new test `tests/fail/stacked_borrows/fnentry_invalidation2.rs`, before this PR, we display this diagnostic: ``` help: <3278> was later invalidated at offsets [0x0..0xc] by a Unique FnEntry retag --> tests/fail/stacked_borrows/fnentry_invalidation2.rs:13:5 | 13 | inner(&mut t); | ^^^^^^^^^^^^^ ``` Which is very misleading. It is not this call itself, but what happens within the call that invalidates the tag we want. With this PR, we get: ``` help: <2798> was later invalidated at offsets [0x0..0xc] by a Unique FnEntry retag inside this call --> tests/fail/stacked_borrows/fnentry_invalidation2.rs:20:13 | 20 | let _ = t.sli.as_mut_ptr(); | ^^^^^^^^^^^^^^^^^^ ``` Which is much better.
Running https://gist.github.com/SparkyPotato/a32487ed62d8c28acbac2d4df9129af7 in miri, it errors with:
However, the stacked borrow violation is in lines
123
and126
, wheredata: [u8]
is autorefed to a&mut [u8]
for[u8]::as_mut_ptr
.While the span is technically correct, it doesn't help when trying to track where the reference actually came from.
The text was updated successfully, but these errors were encountered: