- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
C-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/SoundnessP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This is a case of undefined behavior around unwinding that will not be fixed by the stabilization of the "C-unwind" ABI.
Suppose there exists a C++ library with this function:
void cpp_unwind() {
    throw "gotcha";
}If this function is compiled as part of a crate with panic=unwind:
extern "C-unwind" {
    cpp_unwind()
}
pub fn unwinds() { unsafe { cpp_unwind() } }...and then called from a crate compiled with panic=abort, the behavior is undefined, because the calling function will be compiled with the assumption that unwinding is impossible.
Note:
- If cpp_unwindis declared withextern "C", the behavior will be well-defined: the runtime will abort even ifpanic=unwindis used.
- Cargo does not support mixing panic modes like this, so this situation is only possible by invoking rustcdirectly (or via a different build system).
- The unwind must originate outside of Rust, because only one panic!()implementation will be linked in the final binary, so usingpanic=abortwill preventpanic!()from unwinding the stack in the first place.
Metadata
Metadata
Assignees
Labels
C-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/SoundnessP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.