Skip to content

Conversation

@aheejin
Copy link
Member

@aheejin aheejin commented Jan 7, 2026

getExceptionMessage didn't work with -sASSERTIONS, which is the default mode for -O0, because getExceptionMessage assumes the input ptr is a pointer, whereas when ASSERTIONS is set, it is an instance of CppException. in/decrementExceptionRefcount have the same problem. Now these methods check whether the pointer is a value or an instance of CppException.

Fixes #17115 (comment).

`getExceptionMessage` didn't work with `-sASSERTIONS`, which is the
default mode for `-O0`, because `getExceptionMessage` assumes the input
`ptr` is a pointer, whereas when `ASSERTIONS` is set, it is an instance
of `CppException`. `in/decrementExceptionRefcount` have the same
problem. Now these methods check whether the pointer is a value or an
instance of `CppException`.

Fixes
emscripten-core#17115 (comment).
Copy link
Collaborator

@kleisauke kleisauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!


@with_all_eh_sjlj
def test_EXPORT_EXCEPTION_HANDLING_HELPERS(self):
self.set_setting('ASSERTIONS', 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to just remove this line. No need for the additional change below since core tests run in O0 mode with assertions enabled already.

if (ptr instanceof CppException) {
ptr = ptr.excPtr;
}
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit on that ptr might be something other than a pointer. Why not expect caller to always pass a pointer here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EH] Fix inconsistency of refcounting in Emscripten EH vs. Wasm EH

3 participants