-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Don't call env::set_var
in rustc_driver::install_ice_hook
#125063
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
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.
This only sets the style, but without the env. variable, this will think that backtraces are disabled.
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.
Interesting, TIL.
Do you know if that is relevant in this context?
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.
Hmm. I thought that it is, otherwise I wouldn't comment, but now that I look at it, maybe it isn't. The default panic hook does not seem to use
Backtrace::capture
and reads the style directly.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.
Good catch, @Kobzol!
Yes, this is relevant here. We want to enable backtraces (unless there is an explicit setting for it).
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.
I'm not sure if the compiler calls
Backtrace::capture
somewhere explicitly, or if it just depends on the default panic hook. If the latter is true, then maybe we really don't need to set the env. variable.That being said, wrapping this line with
unsafe
seems fine to me, it's not like the compiler uses#[forbid_unsafe_code)]
anyway, and this line has been clearly working fine in the past.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.
We want to make the default hook here always print a backtrace. We can't change the default hook to use
Backtrace::force_capture
. We would have to copy it from libstd into this function instead and make sure to keep it in sync.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.
This behavior is still preserved, unless I'm mistaken. As @Kobzol pointed out, the default hook does not depend on the RUST_BACKTRACE env var. My comment about
force_capture
was wrt to @Kobzol's concern that other (possibly future) code somewhere in the compiler might rely on this code setting the RUST_BACKTRACE env var if no explicit setting is provided.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 are uses of
Backtrace::capture
in compiler/rustc_errors/src/lib.rs and compiler/rustc_log/src/lib.rs. Should those be changed somehow?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 depends on whether these call sites want to depend on the RUST_BACKTRACE env var or not.
For rustc_log, it looks like that should indeed use
force_capture
.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.
I've opened #125355 for the rustc_log case.
I'm less sure about the compiler/rustc_errors/src/lib.rs cases but I think these should use force_capture too. @tbu-, do you want to open a PR, so we can engage with the diagnostics team?
Thanks for reporting this, @RalfJung!