about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHood Chatham <roberthoodchatham@gmail.com>2022-06-08 10:04:02 -0700
committerHood Chatham <roberthoodchatham@gmail.com>2022-06-08 10:04:02 -0700
commit2ecbdc1b3223eb9acda60014946738cd8e87f7e5 (patch)
treed345239c8dece3fc5663005b82ad9a6bf4ec25d7
parent1a97162cb245b5e2c7458c28859e3df779908c02 (diff)
downloadrust-2ecbdc1b3223eb9acda60014946738cd8e87f7e5.tar.gz
rust-2ecbdc1b3223eb9acda60014946738cd8e87f7e5.zip
Don't use __gxx_personality_v0 in panic_unwind on emscripten target
This resolves #85821. See also the discussion here:
https://github.com/emscripten-core/emscripten/issues/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.
-rw-r--r--library/panic_unwind/src/emcc.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/library/panic_unwind/src/emcc.rs b/library/panic_unwind/src/emcc.rs
index 12f0fe9c3c3..e3a32a5581e 100644
--- a/library/panic_unwind/src/emcc.rs
+++ b/library/panic_unwind/src/emcc.rs
@@ -105,6 +105,11 @@ 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,
@@ -113,7 +118,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" {