Skip to content

Commit 20be5da

Browse files
authoredJun 10, 2022
Rollup merge of #97888 - hoodmane:emscripten-eh-personality, r=Amanieu
Don't use __gxx_personality_v0 in panic_unwind on emscripten target This resolves #85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
2 parents a652a43 + d2d205d commit 20be5da

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed
 

‎library/panic_unwind/src/emcc.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,19 @@ extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void {
105105
}
106106
}
107107

108+
// This is required by the compiler to exist (e.g., it's a lang item), but it's
109+
// never actually called by the compiler. Emscripten EH doesn't use a
110+
// personality function at all, it instead uses __cxa_find_matching_catch.
111+
// Wasm error handling would use __gxx_personality_wasm0.
108112
#[lang = "eh_personality"]
109113
unsafe extern "C" fn rust_eh_personality(
110-
version: c_int,
111-
actions: uw::_Unwind_Action,
112-
exception_class: uw::_Unwind_Exception_Class,
113-
exception_object: *mut uw::_Unwind_Exception,
114-
context: *mut uw::_Unwind_Context,
114+
_version: c_int,
115+
_actions: uw::_Unwind_Action,
116+
_exception_class: uw::_Unwind_Exception_Class,
117+
_exception_object: *mut uw::_Unwind_Exception,
118+
_context: *mut uw::_Unwind_Context,
115119
) -> uw::_Unwind_Reason_Code {
116-
__gxx_personality_v0(version, actions, exception_class, exception_object, context)
120+
core::intrinsics::abort()
117121
}
118122

119123
extern "C" {
@@ -125,11 +129,4 @@ extern "C" {
125129
tinfo: *const TypeInfo,
126130
dest: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void,
127131
) -> !;
128-
fn __gxx_personality_v0(
129-
version: c_int,
130-
actions: uw::_Unwind_Action,
131-
exception_class: uw::_Unwind_Exception_Class,
132-
exception_object: *mut uw::_Unwind_Exception,
133-
context: *mut uw::_Unwind_Context,
134-
) -> uw::_Unwind_Reason_Code;
135132
}

0 commit comments

Comments
 (0)
Please sign in to comment.