-
Notifications
You must be signed in to change notification settings - Fork 417
improve backtrace rendering #4749
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
base: master
Are you sure you want to change the base?
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
b91a126 to
3edb9dc
Compare
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
What I've always wanted here is to do the multi-span diagnostics like the borrow checker uses. If we can pull that off, it may make it clearer because the help spans wouldn't be inserted between the top two components of the backtrace. |
I think this change is definitely good, the information is important and if people read every word of the output text it's clear, but we may discover that some additional clarity is needed. I wouldn't rush it though. I like this part of the PR as-is. |
We can fairly easily just add multiple labels to the main diagnostic, yeah. However, in my brief experiments, we then lose control over the order in which they are rendered -- they are always shown in source code order. That's not ideal for us, the aliasing model errors work better if we show them in execution order. |
|
So as a concrete example, if I just replace the In this example, the "was later invalidated" works out, but this may be shown above the other two labels. |
|
☔ The latest upstream changes (possibly #4763) made this pull request unmergeable. Please resolve the merge conflicts. |
There are several things I don't like about our current backtrace rendering:
= note: BACKTRACE:looks clunkySo here I am trying to improve the situation. The first commit adjusts rendering for the common case to something like this:
The line that says "this is inside" will also show the name of the thread if there is more than 1 thread. That line is shown if there is more than 1 stackframe or more than 1 thread.
The most tricky part is what to do with errors that point are more than one span. If we just add a
= note: this is insidem::f``, that looks like it refers to the last span we showed, when it actually refers to the first. We'll want a full note-with-span here, not just a= note. I decided to have that span point at the surrounding function, e.g.:However, I am not at all tied to this approach and would be happy about better suggestions.
The second commit adds one more span to the bottom of the backtrace for all stacks except the one of
main. That span indicates why this particular function got called:staticitem that carries the magic linker annotation that turns into a constructor/desstructor. See the newctor_ubtest for an example.@rust-lang/miri please let me know what you think.