Skip to content

core2ss.test_wasm_worker_futex_wait regression #26738

Closed

Description

@juj

Seeing this

C:\emsdk\emscripten\main>test\runner core2ss.test_wasm_worker_futex_wait
Running 1 tests
[1/1] test_wasm_worker_futex_wait (test_core.core2ss.test_wasm_worker_futex_wait) ... FAIL

Stdout:
-- begin program output --
Worker sleeping on futex...
Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>)
worker sent an error! Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
node:internal/event_target:1101
  process.nextTick(() => { throw err; });
                           ^

RuntimeError: Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
    at abort (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:6159)
    at ___handle_stack_overflow (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:12797)
    at wasm://wasm/0001364a:wasm-function[44]:0x34af
    at wasm://wasm/0001364a:wasm-function[45]:0x3e2b
    at wasm://wasm/0001364a:wasm-function[39]:0x2fed
    at wasm://wasm/0001364a:wasm-function[38]:0x2685
    at wasm://wasm/0001364a:wasm-function[19]:0x61b
    at C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9729
    at callUserCallback (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9373)
    at _wasmWorkerRunPostMessage (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9681)
    at MessagePort.f (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:4345)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Thrown at:
    at node:internal/event_target:1101:28
    at processTicksAndRejections (node:internal/process/task_queues:85:11)


Node.js v22.16.0
-- end program output --


======================================================================
FAIL: test_wasm_worker_futex_wait (test_core.core2ss.test_wasm_worker_futex_wait)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\emsdk\emscripten\main\test\test_core.py", line 130, in decorated
    return func(self, *args, **kwargs)
  File "C:\emsdk\emscripten\main\test\test_core.py", line 382, in decorated
    return func(self, *args, **kwargs)
  File "C:\emsdk\emscripten\main\test\test_core.py", line 171, in decorated
    return func(self, *args, **kwargs)
  File "C:\emsdk\emscripten\main\test\test_core.py", line 9728, in test_wasm_worker_futex_wait
    self.do_runf('wasm_worker/wasm_worker_futex_wait.c', cflags=['-sWASM_WORKERS'])
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\emsdk\emscripten\main\test\common.py", line 1387, in do_runf
    return self._build_and_run(filename, expected_output, **kwargs)
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\emsdk\emscripten\main\test\common.py", line 1435, in _build_and_run
    js_output = self.run_js(js_file, engine, args,
                            input=input,
                            assert_returncode=assert_returncode,
                            interleaved_output=interleaved_output)
  File "C:\emsdk\emscripten\main\test\common.py", line 1019, in run_js
    self.fail('JS subprocess failed (%s): %s (expected=%s).  Output:\n%s' % (error.cmd, error.returncode, assert_returncode, ret))
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: JS subprocess failed (C:/emsdk/node/22.16.0_64bit/bin/node.exe --stack-trace-limit=50 --trace-uncaught C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js): 1 (expected=0).  Output:
Worker sleeping on futex...
Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>)
worker sent an error! Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
node:internal/event_target:1101
  process.nextTick(() => { throw err; });
                           ^

RuntimeError: Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
    at abort (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:6159)
    at ___handle_stack_overflow (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:12797)
    at wasm://wasm/0001364a:wasm-function[44]:0x34af
    at wasm://wasm/0001364a:wasm-function[45]:0x3e2b
    at wasm://wasm/0001364a:wasm-function[39]:0x2fed
    at wasm://wasm/0001364a:wasm-function[38]:0x2685
    at wasm://wasm/0001364a:wasm-function[19]:0x61b
    at C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9729
    at callUserCallback (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9373)
    at _wasmWorkerRunPostMessage (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9681)
    at MessagePort.f (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:4345)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Thrown at:
    at node:internal/event_target:1101:28
    at processTicksAndRejections (node:internal/process/task_queues:85:11)


Node.js v22.16.0


Stdout:
-- begin program output --
Worker sleeping on futex...
Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>)
worker sent an error! Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
node:internal/event_target:1101
  process.nextTick(() => { throw err; });
                           ^

RuntimeError: Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
    at abort (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:6159)
    at ___handle_stack_overflow (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:12797)
    at wasm://wasm/0001364a:wasm-function[44]:0x34af
    at wasm://wasm/0001364a:wasm-function[45]:0x3e2b
    at wasm://wasm/0001364a:wasm-function[39]:0x2fed
    at wasm://wasm/0001364a:wasm-function[38]:0x2685
    at wasm://wasm/0001364a:wasm-function[19]:0x61b
    at C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9729
    at callUserCallback (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9373)
    at _wasmWorkerRunPostMessage (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:9681)
    at MessagePort.f (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1:4345)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Thrown at:
    at node:internal/event_target:1101:28
    at processTicksAndRejections (node:internal/process/task_queues:85:11)


Node.js v22.16.0
-- end program output --

----------------------------------------------------------------------
Ran 1 test in 1.623s

FAILED (failures=1)

in

http://clbri.com:8010/api/v2/logs/393049/raw_inline

Bisected this back to

4cadbe344f6b9f471a609637588ea6d99a3d100c is the first bad commit
commit 4cadbe344f6b9f471a609637588ea6d99a3d100c
Author: Sam Clegg <[email protected]>
Date:   Wed Apr 8 12:00:47 2026 -0700

    Fix for exceptions in Wasm Workers under node (#26650)

    Under node we install the `uncaughtException` handler in workers (both
    in pthread and wasm worker). This means that `uncaughtException` is sent
    via `postMessage` back to the main thread. See
    https://github.com/nodejs/node/issues/59617 for why we do this.

    However, these message was simply being ignored by the main thread in
    the case of Wasm Workers.

    With this change we honor the `uncaughtException` message and avoid
    completely loosing the uncaught exception.

 src/lib/libwasm_worker.js                      | 12 +++++++++++-
 test/test_core.py                              |  4 ++++
 test/wasm_worker/test_wasm_worker_exceptions.c | 19 +++++++++++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 test/wasm_worker/test_wasm_worker_exceptions.c

Activity

  1. juj commented on Apr 21, 2026

    @juj
    CollaboratorAuthor

    Dropping a -g there prints a cleaner callstack

    RuntimeError: Aborted(stack overflow (Attempt to set SP to 0x00010e30, with stack limits [0x00010ea0 - 0x000112a0]). If you require more stack space build with -sSTACK_SIZE=<bytes>). Build with -sASSERTIONS for more info.
        at abort (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:501:11)
        at ___handle_stack_overflow (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:1000:7)
        at wasm_worker_futex_wait.wasm.pad (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[85]:0x258d)
        at wasm_worker_futex_wait.wasm.fmt_fp (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[86]:0x2dd2)
        at wasm_worker_futex_wait.wasm.printf_core (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[78]:0x204c)
        at wasm_worker_futex_wait.wasm.__vfprintf_internal (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[77]:0x17d0)
        at wasm_worker_futex_wait.wasm.__small_vfprintf (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[89]:0x3245)
        at wasm_worker_futex_wait.wasm.__small_printf (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[41]:0x9f9)
        at wasm_worker_futex_wait.wasm.worker_main (wasm://wasm/wasm_worker_futex_wait.wasm-0009fb12:wasm-function[21]:0x651)
        at C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:768:69
        at callUserCallback (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:744:16)
        at _wasmWorkerRunPostMessage (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:768:19)
        at MessagePort.f (C:\emsdk\emscripten\main\out\test\wasm_worker_futex_wait.js:347:20)
        at [nodejs.internal.kHybridDispatch] (node:internal/event_target:827:20)
        at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
    Thrown at:
        at node:internal/event_target:1101:28
        at processTicksAndRejections (node:internal/process/task_queues:85:11)
    
  2. sbc100 commented on Apr 21, 2026

    @sbc100
    Collaborator

    I wonder if the error was already there but just not being reported prior to the fix in #26650?

  3. juj commented on Apr 21, 2026

    @juj
    CollaboratorAuthor

    That could very well be. The callstack does not seem recursive, so I wonder if the root cause is just that the default callstack size is too small for printf()..

  4. added a commit that references this issue on Apr 21, 2026
    3022279
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions