Skip to content

"C-unwind" ABI is unsound with "-Cpanic=abort" #83116

Closed
@RalfJung

Description

@RalfJung

In the following code, test should explicitly be allowed to unwind:

#![feature(c_unwind)]

extern "C-unwind" {
    fn test();
}

fn main() {
    unsafe { test(); }
}

However, when building this with -Cpanic=abort, we generate LLVM IR as follows:

; Function Attrs: nounwind nonlazybind
declare void @test() unnamed_addr #1

This means unwinding of test is UB, i.e., this is a soundness problem.

This most likely also affects #[unwind(allowed)], but that attribute is slated for removal anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-c_unwind`#![feature(c_unwind)]`I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions