diff options
author | Alon Zakai <azakai@google.com> | 2020-07-14 08:26:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 08:26:32 -0700 |
commit | 78e1e5fb58810fcf25ee9192397baa26e3ee017e (patch) | |
tree | 1c25f0c756eecc11603ebe105cb14e368d01a448 | |
parent | 8dc843d6e2eec2c20e34b8b97338cf35bb6a811d (diff) | |
download | binaryen-78e1e5fb58810fcf25ee9192397baa26e3ee017e.tar.gz binaryen-78e1e5fb58810fcf25ee9192397baa26e3ee017e.tar.bz2 binaryen-78e1e5fb58810fcf25ee9192397baa26e3ee017e.zip |
wasm2c signal handler fixes (#2957)
Use WASM_RT_SETJMP so we use sigsetjmp when we need to.
Also disable signals in emcc+wasm2c in the fuzzer. emcc looks like
unix, so it enters the ifdef to use signals, but wasm has no signals...
-rwxr-xr-x | scripts/fuzz_opt.py | 3 | ||||
-rw-r--r-- | src/tools/wasm2c-wrapper.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index eedb00d73..145a2c543 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -406,6 +406,9 @@ class CompareVMs(TestCaseHandler): run([in_bin('wasm-opt'), wasm, '--emit-wasm2c-wrapper=main.c'] + FEATURE_OPTS) run(['wasm2c', wasm, '-o', 'wasm.c']) compile_cmd = ['emcc', 'main.c', 'wasm.c', os.path.join(self.wasm2c_dir, 'wasm-rt-impl.c'), '-I' + self.wasm2c_dir, '-lm'] + # disable the signal handler: emcc looks like unix, but wasm has + # no signals + compile_cmd += ['-DWASM_RT_MEMCHECK_SIGNAL_HANDLER=0'] if random.random() < 0.5: compile_cmd += ['-O' + str(random.randint(1, 3))] elif random.random() < 0.5: diff --git a/src/tools/wasm2c-wrapper.h b/src/tools/wasm2c-wrapper.h index fb0658ef0..55eed0c35 100644 --- a/src/tools/wasm2c-wrapper.h +++ b/src/tools/wasm2c-wrapper.h @@ -89,7 +89,7 @@ int main(int argc, char** argv) { (*Z_hangLimitInitializerZ_vv)(); // Prepare to call the export, so we can catch traps. - if (setjmp(g_jmp_buf) != 0) { + if (WASM_RT_SETJMP(g_jmp_buf) != 0) { puts("exception!"); } else { // Call the proper export. |