bytecodealliance / wizer

The WebAssembly Pre-Initializer
Apache License 2.0
942 stars 55 forks source link

The default wizer.resume in wizer.h ignores main function return code #68

Closed TerrorJack closed 1 year ago

TerrorJack commented 1 year ago

When using wizer on a wasi command module and wizer.h in C/C++, https://github.com/bytecodealliance/wizer/blob/main/include/wizer.h#L103 silently ignores the main function's non-zero return code. According to https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/crt/crt1-command.c#L48, non-zero return code should be handled by raising the exception via __wasi_proc_exit.

fitzgen commented 1 year ago

cc @sunfishcode

Based on the name __main_void I assume this does not return the return code? So it seems like the non-zero return code handling should happen inside __main_void rather than here in this header. But it seems like that isn't happening?