Description
There currently doesn't seem to be a good way to debug errors involving pointer invalidation due to reborrows under the tree borrows model, i.e. errors of the following form:
error: Undefined Behavior: write access through <31989684> at alloc18827939[0x10] is forbidden
...
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
= help: the accessed tag <31989684> is a child of the conflicting tag <31895995>
= help: the conflicting tag <31895995> has state Frozen which forbids this child write access
help: the accessed tag <31989684> was created here
...
help: the conflicting tag <31895995> later transitioned to Frozen due to a reborrow (acting as a foreign read access) at offsets [0x0..0x30]
...
= help: this transition corresponds to a loss of write permissions
miri prints a backtrace of the problematic write, but only displays the line of code at which the the problematic reborrow happened. Notably, it doesnt print the tag created by the reborrow. -Zmiri-track-pointer-tag
doesn't log anything for the reborrow event either.
I've hit a few instances of this error recently and had to resort to writing one-off repro tests and fussing around with breakpoints in my debugger to try to catch the reborrow event manually.
I'd be happy if the error logged the tag created by the reborrow, so that I could then get a backtrace with -Zmiri-track-pointer-tag
. It might also make sense to just print the full backtrace of the reborrow in the error - I needed to know both the write backtrace and the reborrow backtrace in every case that I personally hit.
CC:@saethlin