Skip to content

Fix: On wasm targets, call panic_in_cleanup if panic occurs in cleanup#155249

Open
hoodmane wants to merge 1 commit intorust-lang:mainfrom
hoodmane:wasm-panic-in-cleanup-reland
Open

Fix: On wasm targets, call panic_in_cleanup if panic occurs in cleanup#155249
hoodmane wants to merge 1 commit intorust-lang:mainfrom
hoodmane:wasm-panic-in-cleanup-reland

Conversation

@hoodmane
Copy link
Copy Markdown
Contributor

@hoodmane hoodmane commented Apr 13, 2026

Relies on rust-lang/llvm-project#194.
Reland of #151771.

Previously this was not correctly implemented. Each funclet may need its own terminate block, so this changes the terminate_block into a terminate_blocks IndexVec which can have a terminate_block for each funclet. We key on the first basic block of the funclet -- in particular, this is the start block for the old case of the top level terminate function.

Rather than using a catchswitch/catchpad pair, I used a cleanuppad. The reason for the pair is to avoid catching foreign exceptions on MSVC. On wasm, it seems that the catchswitch/catchpad pair is optimized back into a single cleanuppad and a catch_all instruction is emitted which will catch foreign exceptions. Because the new logic is only used on wasm, it seemed better to take the simpler approach seeing as they do the same thing.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 13, 2026

r? @JohnTitor

rustbot has assigned @JohnTitor.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: codegen, compiler
  • codegen, compiler expanded to 69 candidates
  • Random selection from 13 candidates

@rustbot

This comment has been minimized.

@hoodmane
Copy link
Copy Markdown
Contributor Author

r? @bjorn3

@rustbot rustbot assigned bjorn3 and unassigned JohnTitor Apr 13, 2026
@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 13, 2026

@rustbot blocked LLVM backport and rustc LLVM update need to land first.

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2026
@dianqk dianqk mentioned this pull request Apr 22, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 23, 2026
Update LLVM to 22.1.4

Unlocks #155249.

I made a new branch that removes CI checks for macOS and reverts rust-lang/llvm-project@24b53fb.
rust-bors Bot pushed a commit that referenced this pull request Apr 24, 2026
Update LLVM to 22.1.4

Unlocks #155249.

I made a new branch that removes CI checks for macOS and reverts rust-lang/llvm-project@24b53fb.
@rust-bors

This comment has been minimized.

renovate-bot pushed a commit to renovate-bot/rust-lang-_-compiler-builtins that referenced this pull request Apr 26, 2026
Update LLVM to 22.1.4

Unlocks rust-lang/rust#155249.

I made a new branch that removes CI checks for macOS and reverts rust-lang/llvm-project@24b53fb.
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 27, 2026
Update LLVM to 22.1.4

Unlocks rust-lang/rust#155249.

I made a new branch that removes CI checks for macOS and reverts rust-lang/llvm-project@24b53fb.
@rust-bors

This comment has been minimized.

@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 28, 2026

@bors author

The backport has happened.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 28, 2026

Unknown command "author". Run @bors help to see available commands.

@mati865
Copy link
Copy Markdown
Member

mati865 commented Apr 28, 2026

@rustbot author

@rustbot rustbot removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 28, 2026
Previously this was not correctly implemented. Each funclet may need its own terminate
block, so this changes the `terminate_block` into a `terminate_blocks` `IndexVec` which
can have a terminate_block for each funclet. We key on the first basic block of the
funclet -- in particular, this is the start block for the old case of the top level
terminate function.

Rather than using a catchswitch/catchpad pair, I used a cleanuppad. The reason for the
pair is to avoid catching foreign exceptions on MSVC. On wasm, it seems that the
catchswitch/catchpad pair is optimized back into a single cleanuppad and a catch_all
instruction is emitted which will catch foreign exceptions. Because the new logic is
only used on wasm, it seemed better to take the simpler approach seeing as they do the
same thing.
@hoodmane hoodmane force-pushed the wasm-panic-in-cleanup-reland branch from 9664e4c to b072d24 Compare April 28, 2026 16:56
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@hoodmane
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

5 participants