diff --git a/src/lib/libexceptions.js b/src/lib/libexceptions.js index 4f763f63ae80f..5596827f15a2d 100644 --- a/src/lib/libexceptions.js +++ b/src/lib/libexceptions.js @@ -345,14 +345,25 @@ var LibraryExceptions = { }, #elif !DISABLE_EXCEPTION_CATCHING - $incrementExceptionRefcount__deps: ['__cxa_increment_exception_refcount'], - $incrementExceptionRefcount: (ptr) => ___cxa_increment_exception_refcount(ptr), + // When EXCEPTION_STACK_TRACES is set, the exception is an instance of + // CppException, whereas EXCEPTION_STACK_TRACES is unset it is a raw pointer. + $exnToPtr: (exn) => { +#if EXCEPTION_STACK_TRACES + if (exn instanceof CppException) { + return exn.excPtr; + } +#endif + return exn; + }, + + $incrementExceptionRefcount__deps: ['$exnToPtr', '__cxa_increment_exception_refcount'], + $incrementExceptionRefcount: (exn) => ___cxa_increment_exception_refcount(exnToPtr(exn)), - $decrementExceptionRefcount__deps: ['__cxa_decrement_exception_refcount'], - $decrementExceptionRefcount: (ptr) => ___cxa_decrement_exception_refcount(ptr), + $decrementExceptionRefcount__deps: ['$exnToPtr', '__cxa_decrement_exception_refcount'], + $decrementExceptionRefcount: (exn) => ___cxa_decrement_exception_refcount(exnToPtr(exn)), - $getExceptionMessage__deps: ['$getExceptionMessageCommon'], - $getExceptionMessage: (ptr) => getExceptionMessageCommon(ptr), + $getExceptionMessage__deps: ['$exnToPtr', '$getExceptionMessageCommon'], + $getExceptionMessage: (exn) => getExceptionMessageCommon(exnToPtr(exn)), #endif }; diff --git a/test/test_core.py b/test/test_core.py index e48cb67f309f5..f62335a23f6b9 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -1508,7 +1508,6 @@ def test_exceptions_rethrow_missing(self): @with_all_eh_sjlj def test_EXPORT_EXCEPTION_HANDLING_HELPERS(self): - self.set_setting('ASSERTIONS', 0) self.set_setting('EXPORT_EXCEPTION_HANDLING_HELPERS') self.maybe_closure()