Skip to content

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

Open
RalfJung wants to merge 1 commit into
rust-lang:mainfrom
RalfJung:no-unwind-abi-check
Open

interpret: ensure that calls via no-unwind ABIs do not unwind#161628
RalfJung wants to merge 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

rustbot commented Aug 24, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants