-
Notifications
You must be signed in to change notification settings - Fork 14k
Show backtrace on allocation failures when possible #148020
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
And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.
|
The Miri subtree was changed cc @rust-lang/miri |
|
rustbot has assigned @Mark-Simulacrum. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with safety comment removed or clarified, if we don't want review from Mara or Amanieu. (Or think this needs libs-api signoff since it's sort of new public feature).
library/std/src/alloc.rs
Outdated
| let mut lock = crate::sys::backtrace::lock(); | ||
|
|
||
| match crate::panic::get_backtrace_style() { | ||
| // SAFETY: we took out a lock just a second ago. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me what this safety comment is on - I don't see any unsafe code here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BacktraceLock::print is incorrectly marked as safe. It and all callers should be marked unsafe. See 1c8f9bb?w=1#diff-1b221b9e32f6143fdd8a5505c8893377e8e9eb1ff47b988716343c7e70393b1bR40.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it not safe? The mere fact that you have a BacktraceLock (which you need to call print) means that no other thread can be printing a backtrace, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, right. probably the safety comment should just be moved inside that function then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.
Split out of #147725 to allow landing this independently of a decision whether or not to remove
-Zoom=panic.