-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-panicArea: Panicking machineryArea: Panicking machineryA-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/SoundnessP-highHigh priorityHigh priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
The personality function takes an _Unwind_Action
as an argument.
rust/library/std/src/sys/personality/gcc.rs
Lines 208 to 211 in d497e43
unsafe extern "C" fn rust_eh_personality_impl( | |
version: c_int, | |
actions: uw::_Unwind_Action, | |
_exception_class: uw::_Unwind_Exception_Class, |
This is declared in the unwind crate as an enum
rust/library/unwind/src/unwinding.rs
Lines 5 to 13 in d497e43
#[repr(C)] | |
#[derive(Copy, Clone, PartialEq)] | |
pub enum _Unwind_Action { | |
_UA_SEARCH_PHASE = 1, | |
_UA_CLEANUP_PHASE = 2, | |
_UA_HANDLER_FRAME = 4, | |
_UA_FORCE_UNWIND = 8, | |
_UA_END_OF_STACK = 16, | |
} |
But in reality, this is actually bit flags:
Indicates what processing the personality routine is expected to perform, as a bit
mask. The possible actions are described below.
(from https://gitlab.com/x86-psABIs/x86-64-ABI 6.2.6)
This means that invalid values are being passed to this function, which is undefined behavior (since the only valid values for an enum are its exact variants).
(found by @pitust)
Metadata
Metadata
Assignees
Labels
A-panicArea: Panicking machineryArea: Panicking machineryA-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/SoundnessP-highHigh priorityHigh priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.