Fix lto0.test_exceptions_allowed_uncaught failure#19165
Conversation
e4c6dd2 to
e595b62
Compare
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); ``` For some reason the LTO build produces the following for for the call to `exception_header->exceptionDestructor(thrown_object)` in `__cxa_decrement_exception_refcount`: ``` call_indirect 0 (type 0) ``` Where as the normal non-LTO build produces: ``` call 13 <invoke_ii> ``` Because invoke_ii goes via JS it uses the sloppy type checking and doesn't trap, but `call_indirect` has strict type checking and so does trap.
e595b62 to
7920939
Compare
|
I figured out the problem. See the new description. |
|
Thanks, I see now. So technically signature was incorrect even before the PR, but because it was used only from JS, it didn't matter? |
| // In wasm, destructors return 'this' as in ARM | ||
| void* (*exceptionDestructor)(void *); |
There was a problem hiding this comment.
I remember adding this years ago... I guess it was somehow lost during library updates. https://github.com/aheejin/emscripten/blob/d57db5bea1719319a680699c50b91fa3d88fa0ec/system/lib/libcxxabi/src/cxa_exception.hpp#L41-L46
By the way, wouldn't it be better to add ifdef as in the old code, in case when we try to upstream our changes?
There was a problem hiding this comment.
This entire block is already within #ifdef __USING_EMSCRIPTEN_EXCEPTIONS__.
BTW, is there some way we can undef the destructors return 'this' as in ARM decision, since it makes all these patches needed? Is there some reason we need this behaviour?
There was a problem hiding this comment.
Maybe? AFAIK @sunfishcode added that way back at the beginning, as a performance optimization. I don't know how much impact it actually has.
This test started failing after #16627. Prior to that change the exceptions destructors were called via the following code in JS:
For some reason the LTO build produces the following for for the call
to
exception_header->exceptionDestructor(thrown_object)in__cxa_decrement_exception_refcount:Where as the normal non-LTO build produces:
Because invoke_ii goes via JS it uses the sloppy type checking and
doesn't trap, but
call_indirecthas strict type checking and sodoes trap.