-
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
Use panic::set_hook
to print the ICE message
#60584
Conversation
r? @Zoxc (suggested by GitHub) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
src/librustdoc/lib.rs
Outdated
@@ -444,7 +444,8 @@ where R: 'static + Send, | |||
|
|||
let (tx, rx) = channel(); | |||
|
|||
let result = rustc_driver::report_ices_to_stderr_if_any(move || { | |||
rustc_driver::install_ice_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.
This may cause problem for tests. We don't want to use the custom panic hook for them.
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 played around with this for a bit and couldn't notice any rustdoc changes, except that ICEs while building a test are missing the query stack for some reason, which seems odd.
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.
Correction: The hook in this PR never seems to be called when doing rustdoc --test bla.rs
. On nightly, the query stack hook still runs, but the normal ICE message isn't printed.
run_compiler
is apparently only called for building documentation, not for running tests.
I'll change it to also register the hook when running doctests, since that matches the old behavior more closely, and having proper ICE messages there is a useful thing.
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.
The ICE message printed by the hook ends up escaping libtest's output capturing, so it looks really jarring. I've removed this line instead. The only thing lost is the query stack. A user will still see that an ICE is an ICE and can extract it into a non-doctest instead.
Let me know if this isn't good enough. Ideally we'd rework how rustdoc runs tests entirely so it behaves closer to the normal rustc frontend, but that's clearly out of scope for this PR.
This comment has been minimized.
This comment has been minimized.
@QuietMisdreavus Do you know enough about how panics are handled in rustdoc to review this? |
@QuietMisdreavus is no longer reviewing PRs, so maybe @GuillaumeGomez can help with the rustdoc-specific changes in here? |
I confirm that rustdoc changes look good. But we still need the @rust-lang/compiler team to take a look. |
☔ The latest upstream changes (presumably #57428) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm not 100% sure how this would be used by custom drivers to overwrite the panic behavior. Maybe add some docs and/or show it in a custom driver test. The impl lgtm |
AFAIK, rustdoc doesn't do anything special to handle panics when building docs, that rustc doesn't already do - there's a thread spawned in When running doctests, though, it called Once when collecting doctests: Lines 80 to 117 in 51dc52b
And once per-doctest to compile them: Lines 327 to 338 in 51dc52b
In addition, there's some manual work with parsers during Lines 202 to 212 in 51dc52b
I'm not sure what the desired approach is in this situation, but i or @euclio could provide more information if needed. |
r? @oli-obk |
Ping from Triage, @oli-obk @jonas-schievink - any update on this PR? Thanks! |
Yeah, sorry for dropping the ball on this. I'll get to this soon, I hope. |
Okay, rebased this and added docs. |
Just one question and then it's good to go for me. |
@bors r=oli-obk |
📌 Commit dab6813 has been approved by |
Use `panic::set_hook` to print the ICE message This allows custom frontends and backends to override the hook with their own, for example to point people to a different issue tracker. ICE messages are printed in a slightly different order now. Nightly prints: ``` thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.36.0-nightly (08bfe16 2019-05-02) running on x86_64-unknown-linux-gnu ``` After this PR, rustc prints: ``` thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.36.0-dev running on x86_64-unknown-linux-gnu error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. ```
☀️ Test successful - checks-azure |
Tested on commit rust-lang/rust@572d3d9. Direct link to PR: <rust-lang/rust#60584> 💔 rls on windows: test-fail → build-fail (cc @Xanewok, @rust-lang/infra). 💔 rls on linux: test-fail → build-fail (cc @Xanewok, @rust-lang/infra).
Caused by rust-lang/rust#60584
Caused by rust-lang/rust#60584
Caused by rust-lang/rust#60584
update for rustc changes rust-lang/rust#60584 changed some stuff around ICEs. What I am not sure about is whether we should call `install_ice_hook` or not. @jonas-schievink @oli-obk any advice?
This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes rust-lang#2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes rust-lang#2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
Add custom ICE message that points to Clippy repo changelog: Link to Clippy issue tracker in ICE messages This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes #2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
Add custom ICE message that points to Clippy repo changelog: Link to Clippy issue tracker in ICE messages This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes #2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes rust-lang#2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes rust-lang#2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes rust-lang#2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
Add custom ICE message that points to Clippy repo changelog: Link to Clippy issue tracker in ICE messages This utilizes rust-lang/rust#60584 by setting our own `panic_hook` and pointing to our own issue tracker instead of the rustc issue tracker. This also adds a new internal lint to test the ICE message. **Potential downsides** * This essentially copies rustc's `report_ice` function as `report_clippy_ice`. I think that's how it's meant to be implemented, but maybe @jonas-schievink could have a look as well =) The downside of more-or-less copying this function is that we have to maintain it as well now. The original function can be found [here][original]. * `driver` now depends directly on `rustc` and `rustc_errors` Closes #2734 [original]: https://github.com/rust-lang/rust/blob/59367b074f1523353dddefa678ffe3cac9fd4e50/src/librustc_driver/lib.rs#L1185
This allows custom frontends and backends to override the hook with their own, for example to point people to a different issue tracker.
ICE messages are printed in a slightly different order now. Nightly prints:
After this PR, rustc prints: