Skip to content

Cannot use setjmp with SIDE_MODULE=1 #6047

@CGamesPlay

Description

@CGamesPlay

Hello, I have a strange case that I believe is a bug, unless I'm misunderstanding something. Given a simple file that calls setjmp:

#include <setjmp.h>

int main() {
  jmp_buf b;
  setjmp(b);
  return 0;
}

If you compile this file with SIDE_MODULE=1, you get an assertion failure in asm2wasm:

$ emcc -s WASM=1 -O2 -s SIDE_MODULE=1 test.c
WARNING:root:BINARYEN_ASYNC_COMPILATION disabled due to user options. This will reduce performance and compatibility (some browsers limit synchronous compilation), see https://github.com/kripken/emscripten/wiki/WebAssembly#codegen-effects
Assertion failed: (infos->count(curr->target) > 0), function visitCall, file /Users/rpatterson/.emscripten_ports/binaryen/binaryen-version_40/src/passes/Inlining.cpp, line 89.
Traceback (most recent call last):
  File "/usr/local/bin/emcc", line 13, in <module>
    emcc.run()
  File "/usr/local/Cellar/emscripten/1.37.28/libexec/emcc.py", line 1886, in run
    wasm_text_target, misc_temp_files, optimizer)
  File "/usr/local/Cellar/emscripten/1.37.28/libexec/emcc.py", line 2358, in do_binaryen
    subprocess.check_call(cmd)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/rpatterson/.emscripten_ports/binaryen/binaryen-version_40/bin/asm2wasm', 'a.out.asm.js', '--total-memory=16777216', '--trap-mode=allow', '-O2', '--table-max=-1', '--mem-max=-1', '-o', 'a.out.wasm']' returned non-zero exit status -6

$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.37.28 ()

This is confusing to me because the following works just fine:

$ cat test.c
#include <setjmp.h>

int main() {
  jmp_buf b;
  _setjmp(b);
  return 0;
}

$ emcc -s WASM=1 -O2 -s SIDE_MODULE=1 test.c
WARNING:root:BINARYEN_ASYNC_COMPILATION disabled due to user options. This will reduce performance and compatibility (some browsers limit synchronous compilation), see https://github.com/kripken/emscripten/wiki/WebAssembly#codegen-effects

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions