Skip to content

Commit 52698d0

Browse files
committed
Fix lto0.test_exceptions_allowed_uncaught failure
This test started failing after #16627. Prior to that change the exceptions destructors were called via the following code in JS: ``` // In Wasm, destructors return 'this' as in ARM {{{ makeDynCall('pp', 'destructor') }}}(info.excPtr); ``` I'm not sure why this test only started failing under LTO. Its seems like it should be failing under non-LTO too.
1 parent 437c7b3 commit 52698d0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ jobs:
492492
title: "core3+extras"
493493
test_targets: "
494494
lto2.test_dylink_syslibs_all
495+
lto0.test_exceptions_allowed_uncaught
495496
core3
496497
core2g.test_externref
497498
corez.test_dylink_iostream

system/lib/libcxxabi/src/cxa_exception.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace __cxxabiv1 {
2424
struct _LIBCXXABI_HIDDEN __cxa_exception {
2525
size_t referenceCount;
2626
std::type_info *exceptionType;
27-
void (*exceptionDestructor)(void *);
27+
// In wasm, destructors return 'this' as in ARM
28+
void* (*exceptionDestructor)(void *);
2829
uint8_t caught;
2930
uint8_t rethrown;
3031
void *adjustedPtr;

system/lib/libcxxabi/src/cxa_exception_emscripten.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
// Define to enable extra debugging on stderr.
2222
#if EXCEPTIONS_DEBUG
23-
#define DEBUG printf
23+
#include "emscripten/console.h"
24+
#define DEBUG _emscripten_errf
2425
#else
2526
#define DEBUG(...)
2627
#endif
@@ -141,7 +142,7 @@ void __cxa_decrement_exception_refcount(void *thrown_object) _NOEXCEPT {
141142
assert(exception_header->referenceCount > 0);
142143
if (std::__libcpp_atomic_add(&exception_header->referenceCount, size_t(-1)) == 0 && !exception_header->rethrown)
143144
{
144-
DEBUG("DEL: %p\n", thrown_object);
145+
DEBUG("DEL: %p (dtor=%p)\n", thrown_object, exception_header->exceptionDestructor);
145146
if (NULL != exception_header->exceptionDestructor)
146147
exception_header->exceptionDestructor(thrown_object);
147148
__cxa_free_exception(thrown_object);

0 commit comments

Comments
 (0)