Skip to content

interpret: ensure that calls via no-unwind ABIs do not unwind - #161628

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:no-unwind-abi-check
Aug 27, 2026
Merged

interpret: ensure that calls via no-unwind ABIs do not unwind#161628
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:no-unwind-abi-check

Conversation

@RalfJung

@RalfJung RalfJung commented Aug 23, 2026

Copy link
Copy Markdown
Member

According to our ABI docs, programs like this are okay:

extern "C-unwind" fn does_not_unwind_but_could() {}

fn main() {
    let f: extern "C-unwind" fn() = does_not_unwind_but_could;
    let f: extern "C" fn() = unsafe { std::mem::transmute(f) };
    f();
}

So let's add a test for that.

And also, let's adjust the checks in Miri's shims accordingly (see src/tools/miri/src/shims/sig.rs). We used to reject calls to functions that might unwind with a signature that does not allow unwinding, even if no unwinding occurred. I don't think we have an actual example of a potentially-unwinding shim with an ABI that has a compatible ABI that does not allow unwinding ("C-unwind" and "C"), so we can't add a test for this.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 23, 2026
@RalfJung
RalfJung force-pushed the no-unwind-abi-check branch from 21d1c2a to d1e3bca Compare August 24, 2026 06:23
@RalfJung
RalfJung marked this pull request as ready for review August 24, 2026 06:24
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 24, 2026
@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @oli-obk, @lcnr

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 24, 2026
@rustbot

rustbot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

r? @mati865

rustbot has assigned @mati865.
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: compiler, mir
  • compiler, mir expanded to 75 candidates
  • Random selection from 19 candidates

@rust-bors

This comment has been minimized.

@RalfJung
RalfJung force-pushed the no-unwind-abi-check branch from d1e3bca to 1c53cd0 Compare August 24, 2026 07:28
@rustbot

This comment has been minimized.

@mati865

mati865 commented Aug 24, 2026

Copy link
Copy Markdown
Member

Should be reviewed by somebody more knowledgeable in this area.
@rustbot reroll

@rustbot rustbot assigned jackh726 and unassigned mati865 Aug 24, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

r? @saethlin

@rustbot rustbot assigned saethlin and unassigned jackh726 Aug 24, 2026
@rust-bors

This comment has been minimized.

@RalfJung
RalfJung force-pushed the no-unwind-abi-check branch from 1c53cd0 to 5965328 Compare August 25, 2026 20:09
@rustbot

rustbot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

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.

@saethlin

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5965328 has been approved by saethlin

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Aug 27, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 27, 2026
…ethlin

interpret: ensure that calls via no-unwind ABIs do not unwind

According to our [ABI docs](https://doc.rust-lang.org/nightly/std/primitive.fn.html#abi-compatibility), programs like this are okay:
```rust
extern "C-unwind" fn does_not_unwind_but_could() {}

fn main() {
    let f: extern "C-unwind" fn() = does_not_unwind_but_could;
    let f: extern "C" fn() = unsafe { std::mem::transmute(f) };
    f();
}
```
So let's add a test for that.

And also, let's adjust the checks in Miri's shims accordingly (see `src/tools/miri/src/shims/sig.rs`). We used to reject calls to functions that *might* unwind with a signature that does not allow unwinding, even if no unwinding occurred. I don't think we have an actual example of a potentially-unwinding shim with an ABI that has a compatible ABI that does not allow unwinding ("C-unwind" and "C"), so we can't add a test for this.
rust-bors Bot pushed a commit that referenced this pull request Aug 27, 2026
Rollup of 7 pull requests

Successful merges:

 - #150075 (Implement clamp_to)
 - #161034 (Add SVE-accelerated Vec::retain_mut for aarch64)
 - #161628 (interpret: ensure that calls via no-unwind ABIs do not unwind)
 - #161012 (borrowck: Normalize non-rigid aliases in NLL type relating)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161813 (Change `is_eligible_for_coverage` from a hook to a query)
 - #161842 (chore: fix cargo lints)
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 27, 2026
…ethlin

interpret: ensure that calls via no-unwind ABIs do not unwind

According to our [ABI docs](https://doc.rust-lang.org/nightly/std/primitive.fn.html#abi-compatibility), programs like this are okay:
```rust
extern "C-unwind" fn does_not_unwind_but_could() {}

fn main() {
    let f: extern "C-unwind" fn() = does_not_unwind_but_could;
    let f: extern "C" fn() = unsafe { std::mem::transmute(f) };
    f();
}
```
So let's add a test for that.

And also, let's adjust the checks in Miri's shims accordingly (see `src/tools/miri/src/shims/sig.rs`). We used to reject calls to functions that *might* unwind with a signature that does not allow unwinding, even if no unwinding occurred. I don't think we have an actual example of a potentially-unwinding shim with an ABI that has a compatible ABI that does not allow unwinding ("C-unwind" and "C"), so we can't add a test for this.
rust-bors Bot pushed a commit that referenced this pull request Aug 27, 2026
Rollup of 6 pull requests

Successful merges:

 - #161034 (Add SVE-accelerated Vec::retain_mut for aarch64)
 - #161628 (interpret: ensure that calls via no-unwind ABIs do not unwind)
 - #161012 (borrowck: Normalize non-rigid aliases in NLL type relating)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161813 (Change `is_eligible_for_coverage` from a hook to a query)
 - #161842 (chore: fix cargo lints)
rust-bors Bot pushed a commit that referenced this pull request Aug 27, 2026
Rollup of 7 pull requests

Successful merges:

 - #161034 (Add SVE-accelerated Vec::retain_mut for aarch64)
 - #161628 (interpret: ensure that calls via no-unwind ABIs do not unwind)
 - #161012 (borrowck: Normalize non-rigid aliases in NLL type relating)
 - #161691 (Assorted bootstrap config refactors (part 1/N))
 - #161813 (Change `is_eligible_for_coverage` from a hook to a query)
 - #161842 (chore: fix cargo lints)
 - #161843 (rustdoc: fix lint `cargo::non_kebab_case_bins`)
@rust-bors
rust-bors Bot merged commit 5e6417b into rust-lang:main Aug 27, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 27, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 27, 2026
Rollup merge of #161628 - RalfJung:no-unwind-abi-check, r=saethlin

interpret: ensure that calls via no-unwind ABIs do not unwind

According to our [ABI docs](https://doc.rust-lang.org/nightly/std/primitive.fn.html#abi-compatibility), programs like this are okay:
```rust
extern "C-unwind" fn does_not_unwind_but_could() {}

fn main() {
    let f: extern "C-unwind" fn() = does_not_unwind_but_could;
    let f: extern "C" fn() = unsafe { std::mem::transmute(f) };
    f();
}
```
So let's add a test for that.

And also, let's adjust the checks in Miri's shims accordingly (see `src/tools/miri/src/shims/sig.rs`). We used to reject calls to functions that *might* unwind with a signature that does not allow unwinding, even if no unwinding occurred. I don't think we have an actual example of a potentially-unwinding shim with an ABI that has a compatible ABI that does not allow unwinding ("C-unwind" and "C"), so we can't add a test for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants