Return error when exception was raised after main thread finishes (#2169)
Currently, if a thread is spawned and raises an exception after the main thread has finished, iwasm returns with success instead of returning 1 (i.e. error). Since wasm_runtime_get_wasi_exit_code waits for all threads to finish and only returns the wasi exit code, this PR performs the exception check again and returns error if an exception was raised.
This commit is contained in:
@ -745,8 +745,12 @@ main(int argc, char *argv[])
|
||||
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
if (ret == 0) {
|
||||
/* propagate wasi exit code. */
|
||||
/* wait for threads to finish and propagate wasi exit code. */
|
||||
ret = wasm_runtime_get_wasi_exit_code(wasm_module_inst);
|
||||
if (wasm_runtime_get_exception(wasm_module_inst)) {
|
||||
/* got an exception in spawned thread */
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -549,8 +549,12 @@ main(int argc, char *argv[])
|
||||
|
||||
#if WASM_ENABLE_LIBC_WASI != 0
|
||||
if (ret == 0) {
|
||||
/* propagate wasi exit code. */
|
||||
/* wait for threads to finish and propagate wasi exit code. */
|
||||
ret = wasm_runtime_get_wasi_exit_code(wasm_module_inst);
|
||||
if (wasm_runtime_get_exception(wasm_module_inst)) {
|
||||
/* got an exception in spawned thread */
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user