This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Get the default panic hook for ICEs, from std::panic::set_hook.#732
Merged
eddyb merged 1 commit intoEmbarkStudios:mainfrom Aug 20, 2021
LykenSol:refrost
Merged
Get the default panic hook for ICEs, from std::panic::set_hook.#732eddyb merged 1 commit intoEmbarkStudios:mainfrom LykenSol:refrost
std::panic::set_hook.#732eddyb merged 1 commit intoEmbarkStudios:mainfrom
LykenSol:refrost
Conversation
khyperia
approved these changes
Aug 20, 2021
khyperia
added a commit
that referenced
this pull request
Aug 21, 2021
* Various fixes and cleanup While working on other patches that ended up not being applicable, I've gathered these changes unrelated to the irrelevant patch. So, submitting them as a seperate change, since the bigger change isn't going in. * Revert change superseded by #732
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tested by adding
-Ztreat-err-as-bugtotest_rustc_flagsintests/src/main.rsand observing that the output does include the panic information printed by the default panic hook (i.e.std's).Background: since the rustup in #716, we've had broken ICEs - they would show this message, and the lines after that, but none of the panic information that is supposed to precede it (and
RUST_BACKTRACE=1did nothing):That's because of an interaction between rust-lang/rust#85640 and our own use of
report_ice- thankfully, @bjorn3 provided a solution that doesn't require upstream changes, in the form of an aspect ofstd::panic::take_hook()I missed: you can keep calling it and it will returnstd's default panic hook, as opposed to crashing and/or returning some kind of noop closure.This is documented on
std::panic::take_hookas such:Knowing that, it's easy to see why you can just call it more than once to both clear any existing panic hooks and get
std's default panic hook - but I went a bit farther to try and guard against strange mishaps.