Skip to content

RangeError: Maximum call stack size exceeded when building libopenmpt test suite with -s WASM=2 or -s WASM=0  #17897

Closed
@manxorist

Description

@manxorist

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.22 (a9981ae2a7dc3c45f833d0b2202f739d87ac05c8)
clang version 16.0.0 (https://github.com/llvm/llvm-project 8491d01cc385d08b8b4f5dd097239ea0009ddc63)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/manx/opt/emsdk/upstream/bin

Failing command line in full:

When building libopenmpt test suite (https://github.com/OpenMPT/openmpt/) with make CONFIG=emscripten TEST=1 ONLY_TEST=1 EMSCRIPTEN_TARGET=all (this implies emscripten specific options -Oz -flto -s WASM=2 -s LEGACY_VM_SUPPORT=1 -Wno-transpile -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s ERROR_ON_MISSING_LIBRARIES=1 -s EXPORT_NAME="'libopenmpt'"), we are seeing:

/home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6281
          if (self instanceof AST_Scope) {
                   ^

RangeError: Maximum call stack size exceeded
    at Function.[Symbol.hasInstance] (<anonymous>)
    at AST_LabeledStatement.<anonymous> (/home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6281:20)
    at /home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6575:24
    at Array.forEach (<anonymous>)
    at display_body (/home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6566:16)
    at /home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6630:19
    at /home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6033:21
    at OutputStream.with_indent (/home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:5998:40)
    at Object.with_block (/home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6032:11)
    at print_braced (/home/manx/opt/emsdk/upstream/emscripten/third_party/terser/terser.js:6629:22)
Traceback (most recent call last):
  File "/home/manx/opt/emsdk/upstream/emscripten/em++.py", line 14, in <module>
    sys.exit(emcc.run(sys.argv))
  File "/home/manx/opt/emsdk/upstream/emscripten/emcc.py", line 1226, in run
    phase_post_link(options, state, wasm_target, wasm_target, target)
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/manx/opt/emsdk/upstream/emscripten/emcc.py", line 2923, in phase_post_link
    phase_binaryen(target, options, wasm_target)
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/manx/opt/emsdk/upstream/emscripten/emcc.py", line 3550, in phase_binaryen
    wasm2js = building.wasm2js(wasm2js_template,
  File "/home/manx/opt/emsdk/upstream/emscripten/tools/building.py", line 1189, in wasm2js
    temp = js_optimizer(temp, passes)
  File "/home/manx/opt/emsdk/upstream/emscripten/tools/building.py", line 622, in js_optimizer
    return js_optimizer.run(filename, passes)
  File "/usr/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/home/manx/opt/emsdk/upstream/emscripten/tools/js_optimizer.py", line 397, in run
    return run_on_js(filename, passes, extra_info=extra_info, just_split=just_split, just_concat=just_concat)
  File "/home/manx/opt/emsdk/upstream/emscripten/tools/js_optimizer.py", line 300, in run_on_js
    filenames = shared.run_multiple_processes(commands, route_stdout_to_temp_files_suffix='js_opt.jo.js')
  File "/home/manx/opt/emsdk/upstream/emscripten/tools/shared.py", line 219, in run_multiple_processes
    raise Exception('Subprocess %d/%d failed (%s)! (cmdline: %s)' % (idx + 1, len(commands), returncode_to_str(finished_process.returncode), shlex_join(commands[idx])))
Exception: Subprocess 4/11 failed (returned 1)! (cmdline: /home/manx/opt/emsdk/node/14.18.2_64bit/bin/node /home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js /tmp/tmp_xb51efl.jsfunc_3.js minifyLocals minifyWhitespace last)
make: *** [Makefile:1310: bin/libopenmpt_test.js] Error 1
manx@appendix:~/projects/openmpt/trunk-1$ internal/fs/utils.js:332
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/tmp/tmptwqcet5c.jsfunc_4.js'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at read (/home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js:20:13)
    at Object.<anonymous> (/home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js:1824:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/tmp/tmptwqcet5c.jsfunc_4.js'
}
internal/fs/utils.js:332
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/tmp/tmpa2sko8el.jsfunc_5.js'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at read (/home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js:20:13)
    at Object.<anonymous> (/home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js:1824:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/tmp/tmpa2sko8el.jsfunc_5.js'
}
internal/fs/utils.js:332
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/tmp/tmpsg1x_27j.jsfunc_6.js'
    at Object.openSync (fs.js:497:3)
    at Object.readFileSync (fs.js:393:35)
    at read (/home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js:20:13)
    at Object.<anonymous> (/home/manx/opt/emsdk/upstream/emscripten/tools/acorn-optimizer.js:1824:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/tmp/tmpsg1x_27j.jsfunc_6.js'
}

Emscripten 3.1.21 worked fine, so this is a regression.

Building libopenmpt itself and not the test suite works also fine ('make CONFIG=emscripten TEST=0 EMSCRIPTEN_TARGET=all`).

Building the test suite with -s WASM=1 instead of -s WASM=2 -s LEGACY_VM_SUPPORT=1 -Wno-transpile works also fine (make CONFIG=emscripten TEST=1 ONLY_TEST=1 EMSCRIPTEN_TARGET=wasm).

Even if it should not be easy to fix on the emscripten side, I would appreciate hints about how I could try to work-around the issue on the libopenmpt side.

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