Skip to content

std personality _Unwind_Action should not be a enum #138558

Closed
@Noratrieb

Description

@Noratrieb

The personality function takes an _Unwind_Action as an argument.

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

#[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 machineryA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityT-libsRelevant to the library 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