Skip to content

Phase 1 unwind failure when a Rust frame containing an aborting drop guard is called from code without unwinding info #110499

Open
@nbdd0121

Description

@nbdd0121

Spawn off from #109672

test.rs:

#[no_mangle]
extern "C" fn d() {
    struct Double;

    impl Drop for Double {
        fn drop(&mut self) {
            std::process::abort();
        }
    }

    let _d = Double;

    panic!("once");
}

test.c:

void d();

int main(void) {
    d();
}

compile with:

rustc -O test.rs --crate-type staticlib
gcc test.c libtest.a
./a.out

and I get:

thread '<unnamed>' panicked at 'once', test.rs:13:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
Aborted

cc @rust-lang/wg-ffi-unwind @nikic
@rustbot label: +T-compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions