about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-10 17:22:30 +0900
committerGitHub <noreply@github.com>2022-06-10 17:22:30 +0900
commit20be5da7122e5fbd9b4acd815a6f69f09363aa8d (patch)
tree39a6ae4aae4fa2dee76aefbdab4ff0c7a20b4bfb
parenta652a4303f39c7e33040b7a595627b04e6c34abf (diff)
parentd2d205d0a87861aaa2ce3a39a65afc35a2beb55a (diff)
downloadrust-20be5da7122e5fbd9b4acd815a6f69f09363aa8d.tar.gz
rust-20be5da7122e5fbd9b4acd815a6f69f09363aa8d.zip
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:
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.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/library/panic_unwind/src/emcc.rs b/library/panic_unwind/src/emcc.rs
index 12f0fe9c3c3..1ee69ff9cb2 100644
--- a/library/panic_unwind/src/emcc.rs
+++ b/library/panic_unwind/src/emcc.rs
@@ -105,15 +105,19 @@ 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,
-    actions: uw::_Unwind_Action,
-    exception_class: uw::_Unwind_Exception_Class,
-    exception_object: *mut uw::_Unwind_Exception,
-    context: *mut uw::_Unwind_Context,
+    _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 {
-    __gxx_personality_v0(version, actions, exception_class, exception_object, context)
+    core::intrinsics::abort()
 }
 
 extern "C" {
@@ -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;
 }