-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-intrinsicsArea: IntrinsicsArea: IntrinsicsA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
Description
There are intrinsics like assert_inhabited
, which can unwind, but use rust-intrinsic
ABI that never unwinds:
rust/compiler/rustc_middle/src/ty/layout.rs
Lines 1091 to 1093 in 6d651a2
| RustIntrinsic | |
| PlatformIntrinsic | |
| Unadjusted => false, |
An example demonstrating the issue. The argument passed to function f
is never dropped, when assert_inhabited
unwinds:
#![feature(core_intrinsics)]
#![feature(never_type)]
struct NoisyDrop(&'static str);
impl Drop for NoisyDrop {
fn drop(&mut self) {
println!("{}", self.0);
}
}
pub fn f<A, B>(_: A) {
core::intrinsics::assert_inhabited::<B>()
}
fn main() {
let _a = NoisyDrop("1");
f::<NoisyDrop, !>(NoisyDrop("2"));
}
$ rustc a.rs && ./a
thread 'main' panicked at 'attempted to instantiate uninhabited type `!`', a.rs:13:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1
Metadata
Metadata
Assignees
Labels
A-intrinsicsArea: IntrinsicsArea: IntrinsicsA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness