Skip to content

Commit

Permalink
Rollup merge of rust-lang#97888 - hoodmane:emscripten-eh-personality,…
Browse files Browse the repository at this point in the history
… r=Amanieu

Don't use __gxx_personality_v0 in panic_unwind on emscripten target

This resolves rust-lang#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.
  • Loading branch information
JohnTitor authored Jun 9, 2022
2 parents 8e7c5fa + 46a3f0f commit 03b0f41
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions library/panic_unwind/src/emcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void {
}
}

// This is required by the compiler to exist (e.g., it's a lang item), but it's
// never actually called by the compiler. Emscripten EH doesn't use a
// personality function at all, it instead uses __cxa_find_matching_catch.
// Wasm error handling would use __gxx_personality_wasm0.
#[lang = "eh_personality"]
unsafe extern "C" fn rust_eh_personality(
version: c_int,
Expand All @@ -113,7 +117,7 @@ unsafe extern "C" fn rust_eh_personality(
exception_object: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context,
) -> uw::_Unwind_Reason_Code {
__gxx_personality_v0(version, actions, exception_class, exception_object, context)
core::intrinsics::abort()
}

extern "C" {
Expand All @@ -125,11 +129,4 @@ extern "C" {
tinfo: *const TypeInfo,
dest: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void,
) -> !;
fn __gxx_personality_v0(
version: c_int,
actions: uw::_Unwind_Action,
exception_class: uw::_Unwind_Exception_Class,
exception_object: *mut uw::_Unwind_Exception,
context: *mut uw::_Unwind_Context,
) -> uw::_Unwind_Reason_Code;
}

0 comments on commit 03b0f41

Please sign in to comment.