Skip to content

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

@aheejin

Description

@aheejin

The place we increase refcount is different in Emscripten EH and Wasm EH, which is explained in detail here:

emscripten/tests/test_core.py

Lines 1689 to 1697 in 2a3bb65

#ifdef __USING_EMSCRIPTEN_EXCEPTION__
// FIXME Currently Wasm EH and Emscripten EH increases
// refcounts in different places. Wasm EH sets the refcount to
// 1 when throwing, and decrease it in __cxa_end_catch.
// Emscripten EH sets the refcount to 0 when throwing, and
// increase it in __cxa_begin_catch, and decrease it in
// __cxa_end_catch. Fix this inconsistency later.
incrementExceptionRefcount(p);
#endif

So if you want to make the code work for both of them, you should put something like #ifdef in the code to prevent memory from leaking. It'd be good to fix this inconsistency.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions