Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a17c2ff

Browse files
authoredMar 17, 2025
Unrolled build for rust-lang#138573
Rollup merge of rust-lang#138573 - Noratrieb:no-unsound-bad-bonk-bonk, r=workingjubilee Make `_Unwind_Action` a type alias, not enum It's bitflags in practice, so an enum is unsound, as an enum must only have the described values. The x86_64 psABI declares it as a `typedef int _Unwind_Action`, which seems reasonable. I made a newtype first but that was more annoying than just a typedef. We don't really use this value for much other than a short check. I ran `x check library --target aarch64-unknown-linux-gnu,x86_64-pc-windows-gnu,x86_64-fortanix-unknown-sgx,x86_64-unknown-haiku,x86_64-unknown-fuchsi a,x86_64-unknown-freebsd,x86_64-unknown-dragonfly,x86_64-unknown-netbsd,x86_64-unknown-openbsd,x86_64-unknown-redox,riscv64-linux-android,armv7-unknown-freebsd` (and some more but they failed to build for other reasons :D) fixes rust-lang#138558 r? workingjubilee have fun
2 parents c3dd4ee + f20a6c7 commit a17c2ff

File tree

3 files changed

+16
-22
lines changed

3 files changed

+16
-22
lines changed
 

‎library/std/src/sys/personality/gcc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ cfg_if::cfg_if! {
220220
Ok(action) => action,
221221
Err(_) => return uw::_URC_FATAL_PHASE1_ERROR,
222222
};
223-
if actions as i32 & uw::_UA_SEARCH_PHASE as i32 != 0 {
223+
if actions & uw::_UA_SEARCH_PHASE != 0 {
224224
match eh_action {
225225
EHAction::None | EHAction::Cleanup(_) => uw::_URC_CONTINUE_UNWIND,
226226
EHAction::Catch(_) | EHAction::Filter(_) => uw::_URC_HANDLER_FOUND,
@@ -230,7 +230,7 @@ cfg_if::cfg_if! {
230230
match eh_action {
231231
EHAction::None => uw::_URC_CONTINUE_UNWIND,
232232
// Forced unwinding hits a terminate action.
233-
EHAction::Filter(_) if actions as i32 & uw::_UA_FORCE_UNWIND as i32 != 0 => uw::_URC_CONTINUE_UNWIND,
233+
EHAction::Filter(_) if actions & uw::_UA_FORCE_UNWIND != 0 => uw::_URC_CONTINUE_UNWIND,
234234
EHAction::Cleanup(lpad) | EHAction::Catch(lpad) | EHAction::Filter(lpad) => {
235235
uw::_Unwind_SetGR(
236236
context,

‎library/unwind/src/libunwind.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,13 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a
128128
//
129129
// 32-bit ARM on iOS/tvOS/watchOS use either DWARF/Compact unwinding or
130130
// "setjmp-longjmp" / SjLj unwinding.
131-
#[repr(C)]
132-
#[derive(Copy, Clone, PartialEq)]
133-
pub enum _Unwind_Action {
134-
_UA_SEARCH_PHASE = 1,
135-
_UA_CLEANUP_PHASE = 2,
136-
_UA_HANDLER_FRAME = 4,
137-
_UA_FORCE_UNWIND = 8,
138-
_UA_END_OF_STACK = 16,
139-
}
140-
pub use _Unwind_Action::*;
131+
pub type _Unwind_Action = c_int;
132+
133+
pub const _UA_SEARCH_PHASE: c_int = 1;
134+
pub const _UA_CLEANUP_PHASE: c_int = 2;
135+
pub const _UA_HANDLER_FRAME: c_int = 4;
136+
pub const _UA_FORCE_UNWIND: c_int = 8;
137+
pub const _UA_END_OF_STACK: c_int = 16;
141138

142139
#[cfg_attr(
143140
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")),

‎library/unwind/src/unwinding.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
use core::ffi::{c_int, c_void};
44

5-
#[repr(C)]
6-
#[derive(Copy, Clone, PartialEq)]
7-
pub enum _Unwind_Action {
8-
_UA_SEARCH_PHASE = 1,
9-
_UA_CLEANUP_PHASE = 2,
10-
_UA_HANDLER_FRAME = 4,
11-
_UA_FORCE_UNWIND = 8,
12-
_UA_END_OF_STACK = 16,
13-
}
14-
pub use _Unwind_Action::*;
5+
pub type _Unwind_Action = c_int;
6+
7+
pub const _UA_SEARCH_PHASE: c_int = 1;
8+
pub const _UA_CLEANUP_PHASE: c_int = 2;
9+
pub const _UA_HANDLER_FRAME: c_int = 4;
10+
pub const _UA_FORCE_UNWIND: c_int = 8;
11+
pub const _UA_END_OF_STACK: c_int = 16;
1512

1613
#[repr(C)]
1714
#[derive(Debug, Copy, Clone, PartialEq)]

0 commit comments

Comments
 (0)
Failed to load comments.