]> git.lizzy.rs Git - rust.git/commit
Auto merge of #96959 - nbdd0121:unwind, r=Amanieu
authorbors <bors@rust-lang.org>
Tue, 17 May 2022 15:04:50 +0000 (15:04 +0000)
committerbors <bors@rust-lang.org>
Tue, 17 May 2022 15:04:50 +0000 (15:04 +0000)
commit00755e4ca68f12ed200e921276788ab19975e85f
tree3eb70385eaa911ef3c3cf4f230a6e2fd6bb303bd
parent3655175a75f503c9855b6a73a9d3c83997354c1d
parentf86e409f0906deefd0871ba823c086dd58b50870
Auto merge of #96959 - nbdd0121:unwind, r=Amanieu

Prevent unwinding when `-C panic=abort` is used regardless declared ABI

Ensures that Rust code will abort with `-C panic=abort` regardless ABI used.
```rust
extern "C-unwind" {
    fn may_unwind();
}

// Will be nounwind with `-C panic=abort`, despite `C-unwind` ABI.
pub unsafe extern "C-unwind" fn rust_item_that_can_unwind() {
    may_unwind();
}
```

Current behaviour is that unwind will propagate through. While the current behaviour won't cause unsoundness it is inconsistent with the text reading of [RFC2945](https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html).

I tweaked `fn_can_unwind` instead of tweaking `AbortUnwindingCalls` because this approach would allow Rust (non-direct) callers to also see that this function is nounwind, so it can prevent excessive landing pads generation.

For more discussions: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/soundness.20in.20mixed.20panic.20mode.

cc `@alexcrichton,` `@BatmanAoD`
r? `@Amanieu`

`@rustbot` label: T-compiler T-lang F-c_unwind
compiler/rustc_middle/src/ty/layout.rs