You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support Asyncify + Try-Catch [Can't build web-gphoto2 with -fwasm-exceptions instead of -fexceptions] #4470
web-gphoto2 builds with pthreads, Asyncify, exceptions and LTO, and I'm not sure which combo is specifically problematic here, but the end result is that it crashes when trying to switch from -fexceptions to -fwasm-exceptions:
// We must handle all control flow above, and all things that can change
// the state, so there should be nothing that can reach here - add it
// earlier as necessary.
// std::cout << *curr << '\n';
WASM_UNREACHABLE("unexpected expression type");
So the issue is supporting the Try control flow structure in that pass. It needs special handling for each one since it needs to be able to resume execution back into the middle.
For Try, the hard part would be to get back into the catch when rewinding... maybe we could construct and throw another exception just to get there? Or maybe we should move the code out of the catch, and guard it with a condition, so it can be reached either from the catch or from a resume, something like that.
changed the title [-]Can't build web-gphoto2 with -fwasm-exceptions instead of -fexceptions[/-][+]Support Asyncify + Try-Catch [Can't build web-gphoto2 with -fwasm-exceptions instead of -fexceptions][/+]on Jan 21, 2022
@allsey87 fwiw I am porting a game of my own from desktop to wasm and I would like to use wasm exceptions but, so far, I will also need ASYNCIFY. So this support would be great.
Activity
RReverser commentedon Jan 21, 2022
cc @kripken @aheejin
kripken commentedon Jan 21, 2022
I think that is this:
binaryen/src/passes/Asyncify.cpp
Lines 995 to 999 in 0604422
So the issue is supporting the Try control flow structure in that pass. It needs special handling for each one since it needs to be able to resume execution back into the middle.
For Try, the hard part would be to get back into the catch when rewinding... maybe we could construct and throw another exception just to get there? Or maybe we should move the code out of the catch, and guard it with a condition, so it can be reached either from the catch or from a resume, something like that.
[-]Can't build web-gphoto2 with -fwasm-exceptions instead of -fexceptions[/-][+]Support Asyncify + Try-Catch [Can't build web-gphoto2 with -fwasm-exceptions instead of -fexceptions][/+]allsey87 commentedon Apr 8, 2022
@RReverser did you find a work around (other than just sticking with
-fexceptions) for this?allsey87 commentedon Apr 8, 2022
This code here seems sufficient enough to reproduce the problem:
compiling with:
em++ -fwasm-exceptions -s WARN_ON_UNDEFINED_SYMBOLS=0 -s ASYNCIFY -s 'ASYNCIFY_IMPORTS=["external_async_function"]' index.cpp -o index.htmlallsey87 commentedon Apr 8, 2022
Tested the same code with the latest versions (as follows) but I seem to hit the same error.
kripken commentedon Apr 8, 2022
Yes, no work has been done on this so far. The work that would need to be done is mentioned in #4470 (comment)
allsey87 commentedon Jun 23, 2023
@RReverser this might be possible soon: #5475
germandiagogomez commentedon Aug 9, 2023
@allsey87 fwiw I am porting a game of my own from desktop to wasm and I would like to use wasm exceptions but, so far, I will also need ASYNCIFY. So this support would be great.
wasm: add recover support
wasm: add recover support
wasm: add recover support