Skip to content

Commit

Permalink
Fix asan.test_format_exception test. NFC (#16397)
Browse files Browse the repository at this point in the history
This test was recently added but was failing under `asan` because
it was leaking the exception objects.
  • Loading branch information
sbc100 authored Feb 26, 2022
1 parent dee641d commit 0f78b87
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ def test_exceptions_rethrow_missing(self):

def test_format_exception(self):
self.set_setting('DISABLE_EXCEPTION_CATCHING', 0)
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$formatException'])
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', ['$formatException', '__cxa_decrement_exception_refcount', '__cxa_increment_exception_refcount'])
self.set_setting('EXPORTED_FUNCTIONS', ['_main', 'formatException', '_emscripten_format_exception', '_free'])
self.maybe_closure()
src = '''
Expand Down Expand Up @@ -1582,7 +1582,13 @@ class myexception : public exception {
try {
Module["_throw_exc"](i);
} catch(p) {
// Because we are catching and handling the exception in JS, the normal
// exception catching C++ code doesn't kick in, so we need to make sure we free
// the exception, if necessary. By incrementing and decrementing the refcount
// we trigger the free'ing of the exception if its refcount was zero.
___cxa_increment_exception_refcount(p);
console.log(Module["formatException"](p).replace(/0x[0-9a-f]*/, "xxx"));
___cxa_decrement_exception_refcount(p);
}
}
});
Expand Down

0 comments on commit 0f78b87

Please sign in to comment.