-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Allow changing the bug report url for the ice hook #85640
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
Conversation
Some changes occured to rustc_codegen_cranelift cc @bjorn3 |
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
r? @bjorn3 |
I opened this PR, so I probably shouldn't review it myself. :) r? @jackh726 |
🤦♀️ whoops |
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.
Honestly, I'm not sure how I feel about this. I feel like most ICEs happen in the frontend, not backend. So usually reporting to rust-lang/rust
is a better idea. So maybe instead it's better to just include some extra information in the ICE report?
I'm probably not the best person to review this, since I'm not really in the loop here.
// Invoke the default handler, which prints the actual panic message and optionally a backtrace | ||
(*DEFAULT_HOOK)(info); | ||
|
||
// Separate the output with an empty line | ||
eprintln!(); | ||
|
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 did this need to be taken out? I guess maybe so the right DEFAULT_HOOK
gets registered?
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.
DEFAULT_HOOK
both gets the default hook and registers the new ice hook with the default bug report url. This means that if you register a custom ice hook that calls report_ice
, the ice hook with the default bug report url will be registered again. It is also easy to get into a cycle where the default ice hook and the custom ice hook recursively call each other on panics.
While this is true for the mature cg_llvm backend, this is not true for cg_clif. I do still sometimes get an ice caused by cg_clif. If the ice is in the frontend, I can redirect the issue to rust-lang/rust. In addition when using cg_clif, it is reasonable for someone to assume that cg_clif caused the issue if it doesn't reproduce with cg_llvm. |
I don't feel comfortable approving this myself (not necessarily because these changes are technically hard, but because this is really a decision that potentially impacts e.g. future codegen backends). Maybe if someone from @rust-lang/compiler wants to weigh in or an MCP, that might be better. |
I think an MCP would be a good idea here, but I approve the general concept. |
Opened rust-lang/compiler-team#436 |
cc @rust-lang/clippy we may want this, too |
Clippy already has this since 2019 👍 rust/src/tools/clippy/src/driver.rs Lines 155 to 159 in 2577825
|
MCP is finished @bors r+ rollup |
📌 Commit 0bc60c0 has been approved by |
Allow changing the bug report url for the ice hook cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1174
☀️ Test successful - checks-actions |
Allow changing the bug report url for the ice hook cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1174
panic::set_hook(Box::new(|info| report_ice(info, BUG_REPORT_URL))); | ||
panic::set_hook(Box::new(|info| { | ||
// Invoke the default handler, which prints the actual panic message and optionally a backtrace | ||
(*DEFAULT_HOOK)(info); | ||
|
||
// Separate the output with an empty line | ||
eprintln!(); | ||
|
||
// Print the ICE message | ||
report_ice(info, BUG_REPORT_URL); | ||
})); |
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 makes report_ice
useless for the situations without enough control over the driver to bypass the SyncLazy::force(&DEFAULT_HOOK);
. Maybe there should be a report_ice_including_default_panic_hook
function that provides the old behavior?
Though ideally the new behavior should probably use a new function name (or better, both should change names, so use sites have to pick).
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.
You can set a panic hook more than once, so you can first get the default hook, then let whatever code forces DEFAULT_HOOK
run and then set the new panic hook.
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.
A report_ice_including_default_panic_hook
function requires the DEFAULT_HOOK
to be forced first to be able to call it without ending in an infinite loop.
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.
so you can first get the default hook
The codegen backend is loaded after DEFAULT_HOOK
is initially forced, so it's impossible to make it work without changes to rustc_driver
. I'll hopefully take a look at it soon and try to come up with a better overall solution. It should be possible to e.g. capture more data into the boxed closure, and the use of a static
is somewhat incidental.
Though the most direct solution is to offer a static
that contains the report URL (and maybe additional e.g. footer), and which can be changed independently of the panic hook.
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.
You could have something like https://github.com/bjorn3/rustc_codegen_cranelift/blob/d498e6d6971575714353f11aa4d3e63a9d2030b2/src/bin/cg_clif.rs#L20-L34 except that you call panic::take_hook()
twice and use the result of the second time as default hook. The first time you take the hook set by rustc_driver and ignore it. The second time you take the default libstd hook.
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.
If no custom hook is registered, the default hook will be returned.
Ah, this behavior documented for std::panic::take_hook
was what I missed, thanks!
cc https://github.com/bjorn3/rustc_codegen_cranelift/issues/1174