Skip to content
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

Call the panic hook for non-unwind panics in proc-macros #123825

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

saethlin
Copy link
Member

As I suggested in #123286 (comment).

If a proc macro causes a non-unwinding panic, proc_macro isn't able to catch the unwind and report the panic as a compile error by passing control back to the compiler. Our only chance to produce any diagnostic is the panic hook, so we should call it.

This scenario has already existed, but has become a lot more interesting now that we're adding more UB-detecting panics to the standard library, and such panics do not unwind.

@saethlin saethlin added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 11, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 11, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 11, 2024
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 12, 2024

📌 Commit d8dc28b has been approved by petrochenkov

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 12, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#123204 (rustdoc: point at span in `include_str!`-ed md file)
 - rust-lang#123223 (Fix invalid silencing of parsing error)
 - rust-lang#123249 (do not add prolog for variadic naked functions)
 - rust-lang#123825 (Call the panic hook for non-unwind panics in proc-macros)
 - rust-lang#123833 (Update stdarch submodule)
 - rust-lang#123841 (Improve diagnostic by suggesting to remove visibility qualifier)
 - rust-lang#123849 (Update E0384.md)
 - rust-lang#123852 (fix typo in library/std/src/lib.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8c86920 into rust-lang:master Apr 12, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 12, 2024
Rollup merge of rust-lang#123825 - saethlin:report-nounwind-panics, r=petrochenkov

Call the panic hook for non-unwind panics in proc-macros

As I suggested in rust-lang#123286 (comment).

If a proc macro causes a non-unwinding panic, `proc_macro` isn't able to catch the unwind and report the panic as a compile error by passing control back to the compiler. Our only chance to produce any diagnostic is the panic hook, so we should call it.

This scenario has already existed, but has become a lot more interesting now that we're adding more UB-detecting panics to the standard library, and such panics do not unwind.
@saethlin saethlin deleted the report-nounwind-panics branch April 12, 2024 18:29
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 18, 2024
@apiraino
Copy link
Contributor

Beta backport accepted as per compiler team on Zulip. A backport PR will be authored by the release team at the end of the current development cycle.

It was also mentiond that it would be nice to have some tests for this patch (although this patch is very targeted).

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 18, 2024
@cuviper cuviper mentioned this pull request Apr 18, 2024
@cuviper cuviper modified the milestones: 1.79.0, 1.78.0 Apr 18, 2024
@cuviper cuviper removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 18, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2024
[beta] backports

- Silence `unused_imports` lint for redundant imports rust-lang#123744
- Call the panic hook for non-unwind panics in proc-macros rust-lang#123825
- rustdoc: check redundant explicit links with correct itemid rust-lang#123905

r? cuviper
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2024
[beta] backports

- Silence `unused_imports` lint for redundant imports rust-lang#123744
- Call the panic hook for non-unwind panics in proc-macros rust-lang#123825
- rustdoc: check redundant explicit links with correct itemid rust-lang#123905
- disable two debuginfo tests under gdb 15 rust-lang#123963

r? cuviper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants