9

Provide slightly better notes when tracking a pointer tag by saethlin · Pull Req...

 3 years ago
source link: https://github.com/rust-lang/miri/pull/1945
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

saethlin commented 28 days ago

edited

I slapped this in as a sort of advanced println-based debugging when trying to figure out a track-raw-pointers finding in smallvec. Perhaps this looks like a good idea to you all?

EDIT: User scenario

Run MIRIFLAGS=-Ztag-raw-pointers cargo miri test, get a diagnostic that looks like

error: Undefined Behavior: trying to reborrow for SharedReadOnly at alloc99465+0x9, but parent tag <265507> does not have an appropriate item in the borrow stack

So now run MIRIFLAGS=-Ztag-raw-pointers -Zmiri-track-pointer-tag=265507 cargo miri test
Old:

note: tracking was triggered
   --> src/lib.rs:822:36
    |
822 |                 vec: NonNull::from(self),
    |                                    ^^^^ popped tracked tag for item [SharedReadOnly for <265507>]
note: tracking was triggered
   --> src/lib.rs:822:36
    |
822 |                 vec: NonNull::from(self),
    |                                    ^^^^ popped tracked tag for item [SharedReadOnly for <265507>] due to Write access for <265356>

So that if a user is now beginning to question their sanity because they don't really understand SB yet, they can then track the tag which caused the parent tag to be removed from the stack to be sure what's going on here:

   --> src/lib.rs:792:5
    |
792 | /     pub fn drain<R>(&mut self, range: R) -> Drain<'_, A>
793 | |     where
794 | |         R: RangeBounds<usize>,
795 | |     {
...   |
824 | |         }
825 | |     }
    | |_____^ created tag 265356

The existing diagnostic can tell you where the tag you'd need was invalidated, but it cannot tell you what and why that tag was invalidated.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK