]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #97033 - nbdd0121:unwind3, r=Amanieu
authorbors <bors@rust-lang.org>
Thu, 19 May 2022 04:04:40 +0000 (04:04 +0000)
committerbors <bors@rust-lang.org>
Thu, 19 May 2022 04:04:40 +0000 (04:04 +0000)
commit50872bdb99c96716ee50a3b9613c395302b99767
tree5d9beb770cd7998b4496faeed8163a6fbbf36fc0
parente6327bc8b8d437b66ff91d9ce798a9eb45310967
parentfbb3c19e0347b21d84b428981e930401b7f81b76
Auto merge of #97033 - nbdd0121:unwind3, r=Amanieu

Remove libstd's calls to `C-unwind` foreign functions

Remove all libstd and its dependencies' usage of `extern "C-unwind"`.

This is a prerequiste of a WIP PR which will forbid libraries calling `extern "C-unwind"` functions to be compiled in `-Cpanic=unwind` and linked against `panic_abort` (this restriction is necessary to address soundness bug #96926).
Cargo will ensure all crates are compiled with the same `-Cpanic` but the std is only compiled `-Cpanic=unwind` but needs the ability to be linked into `-Cpanic=abort`.

Currently there are two places where `C-unwind` is used in libstd:
* `__rust_start_panic` is used for interfacing to the panic runtime. This could be `extern "Rust"`
* `_{rdl,rg}_oom`: a shim `__rust_alloc_error_handler` will be generated by codegen to call into one of these; they can also be `extern "Rust"` (in fact, the generated shim is used as `extern "Rust"`, so I am not even sure why these are not, probably because they used to `extern "C"` and was changed to `extern "C-unwind"` when we allow alloc error hooks to unwind, but they really should just be using Rust ABI).

For dependencies, there is only one `extern "C-unwind"` function call, in `unwind` crate. This can be expressed as a re-export.

More dicussions can be seen in the Zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/210922-project-ffi-unwind/topic/soundness.20in.20mixed.20panic.20mode

`@rustbot` label: T-libs F-c_unwind
library/alloc/src/alloc.rs