From f4f1652b333a0143fad2b2fca4eecfebcf30fcb6 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 1 Sep 2023 08:19:09 +0900 Subject: [PATCH] Revert "Return error when exception was raised after main thread finishes (#2169)" This reverts commit 71d43f3ca18b96c983d0fa8ca45ea658d6f9ee4a. for some reasons, the original commit assumes a trap should win over an exit even if the former is 1 second behind the latter. i don't see any reason it should. in that case, the expected behavior is that the exit likely wins and the other thread won't even reach the code to raise a trap. --- .../test/trap_after_main_thread_finishes.json | 3 --- product-mini/platforms/posix/main.c | 6 +----- product-mini/platforms/windows/main.c | 6 +----- 3 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.json diff --git a/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.json b/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.json deleted file mode 100644 index 9dc1e30d2b..0000000000 --- a/core/iwasm/libraries/lib-wasi-threads/test/trap_after_main_thread_finishes.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "exit_code": 1 -} diff --git a/product-mini/platforms/posix/main.c b/product-mini/platforms/posix/main.c index 5d20fd2932..6d4ada662a 100644 --- a/product-mini/platforms/posix/main.c +++ b/product-mini/platforms/posix/main.c @@ -921,12 +921,8 @@ main(int argc, char *argv[]) #if WASM_ENABLE_LIBC_WASI != 0 if (ret == 0) { - /* wait for threads to finish and propagate wasi exit code. */ + /* 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 diff --git a/product-mini/platforms/windows/main.c b/product-mini/platforms/windows/main.c index b7cf814330..8b1b1f371f 100644 --- a/product-mini/platforms/windows/main.c +++ b/product-mini/platforms/windows/main.c @@ -554,12 +554,8 @@ main(int argc, char *argv[]) #if WASM_ENABLE_LIBC_WASI != 0 if (ret == 0) { - /* wait for threads to finish and propagate wasi exit code. */ + /* 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