From 61d4d2be91b333cea87403621225eb6258be1afa Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Sun, 1 Nov 2026 13:36:41 +0530 Subject: [PATCH] [test] Add test for `STACK_OVERFLOW_CHECK=2` with `BINARYEN_PASS_DEBUG` With `-sSTACK_OVERFLOW_CHECK=2`, `wasm-emscripten-finalize` runs binaryen's stack-check pass with `__handle_stack_overflow` as the handler. The pass builds the call to the handler with the stack pointer's type as its result type, but the handler returns nothing. Finalize does not validate after its passes, so these builds still work. `BINARYEN_PASS_DEBUG=1` makes binaryen validate after each pass, and then the build fails with "Last pass (stack-check) broke validation". The new test builds and runs `hello_world.c` with both settings. It fails until WebAssembly/binaryen#9335 rolls in. --- test/test_other.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_other.py b/test/test_other.py index a6c5eb2b13fb1..9d0e7c0dfc9e3 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -14663,6 +14663,13 @@ def test_stack_overflow(self): cflags=['-O1', '--profiling-funcs'], assert_returncode=NON_ZERO) + # BINARYEN_PASS_DEBUG validates after each binaryen pass, which catches + # invalid IR from the stack-check pass that STACK_OVERFLOW_CHECK=2 runs. + @with_env_modify({'BINARYEN_PASS_DEBUG': '1'}) + def test_stack_overflow_check_pass_debug(self): + self.set_setting('STACK_OVERFLOW_CHECK', 2) + self.do_runf('hello_world.c', 'Hello, world!\n') + @also_with_wasm64 @parameterized({ '': ([],),