Skip to content

GOT.func entry with no import/export: $emscripten_longjmp_jmpbuf #9950

@jeromelaban

Description

@jeromelaban

I'm re-opening an issue here regarding WebAssembly/binaryen#2180, where the 1.39.4 release does not fix the sample below. How does one validate that Binaryen has been updated since the original issue was fixed? Thanks!

#include <setjmp.h>
#include <stdio.h>

typedef struct {
  jmp_buf* jmp;
} jmp_state;

void setjmp_func(jmp_state* s, int level) {
  jmp_buf* prev_jmp = s->jmp;
  jmp_buf c_jmp;

  if (level == 2) {
    longjmp(*(s->jmp), 1);
  }

  if (setjmp(c_jmp) == 0) {
    setjmp_func(s, level + 1);
  }
}

int main() { return 0; }

Built as follows:

emcc \
   test.cpp \
   -o test.wasm \
   -s SIDE_MODULE=1

Activity

sbc100

sbc100 commented on Dec 3, 2019

@sbc100
Collaborator

This example works fine for me on ToT.

How are you installing emscripten? Are you using the emsdk? You can have binaryen report the version to you by passing --version to any of the tools e.g. wasm-opt --version.

Can you post the output of the command (preferable with EMCC_DEBUG=1).

self-assigned this
on Dec 3, 2019
jeromelaban

jeromelaban commented on Dec 3, 2019

@jeromelaban
Author

I'm installing it this way:

git clone https://github.com/emscripten-core/emsdk
cd ~/emsdk
./emsdk install 1.39.4
./emsdk activate 1.39.4

Gives me:

~$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.39.4 (commit c10e3e86e8ead9243473c7148beaa9261956123b)

and

~$ ~/emsdk/upstream/bin/wasm-opt --version
wasm-opt 1.39.1-52-g0c2b5b417

The version of wasm-opt does not seem to be aligned, is this expected ?

jeromelaban

jeromelaban commented on Dec 3, 2019

@jeromelaban
Author

Here is the full log:

$ EMCC_DEBUG=1 emcc \
>    test.cpp \
>    -o test.wasm \
>    -s SIDE_MODULE=1
shared:DEBUG: EM_CONFIG is located in /home/jay/.emscripten
shared:DEBUG: JAVA not defined in /home/jay/.emscripten, using "java"
cache:DEBUG: PID 8731 acquiring multiprocess file lock to Emscripten cache at /home/jay/.emscripten_cache
cache:DEBUG: done
cache:DEBUG: PID 8731 released multiprocess file lock to Emscripten cache at /home/jay/.emscripten_cache
shared:DEBUG: check tells us to use wasm backend
emcc:WARNING: invocation: /home/jay/emsdk/upstream/emscripten/emcc.py test.cpp -o test.wasm -s SIDE_MODULE=1  (in /tmp)
shared:DEBUG: successfully executed /home/jay/emsdk/upstream/bin/clang++ --version
root:DEBUG: Checking JS engine ['/home/jay/emsdk/node/12.9.1_64bit/bin/node']
shared:DEBUG: successfully executed /home/jay/emsdk/node/12.9.1_64bit/bin/node --version
shared:DEBUG: successfully executed /home/jay/emsdk/upstream/bin/llc --version
shared:INFO: (Emscripten: Running sanity checks)
shared:WARNING: java does not seem to exist, required for closure compiler, which is optional (define JAVA in /home/jay/.emscripten if you want it)
shared:WARNING: closure compiler will not be available
emcc:DEBUG: compiling to bitcode
emcc:DEBUG: emcc step "parse arguments and setup" took 0.07 seconds
cache:DEBUG: PID 8731 acquiring multiprocess file lock to Emscripten cache at /home/jay/.emscripten_cache/wasm-obj-pic
cache:DEBUG: done
emcc:DEBUG: compiling source file: test.cpp
shared:DEBUG: successfully executed /home/jay/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=4 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/local/include -std=c++03 -DEMSCRIPTEN test.cpp -Xclang -isystem/home/jay/emsdk/upstream/emscripten/system/include/SDL -c -o /tmp/emscripten_temp/test_0.o -fPIC -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr
emcc:DEBUG: emcc step "compile inputs" took 0.04 seconds
emcc:DEBUG: emcc step "process inputs" took 0.00 seconds
emcc:DEBUG: emcc step "calculate system libraries" took 0.00 seconds
emcc:DEBUG: linking: ['/tmp/emscripten_temp/test_0.o', '-L/home/jay/emsdk/upstream/emscripten/system/local/lib', '-L/home/jay/emsdk/upstream/emscripten/system/lib', '-L/home/jay/.emscripten_cache/wasm-obj-pic']
shared:DEBUG: successfully executed /home/jay/emsdk/upstream/bin/wasm-ld -o /tmp/emscripten_temp/test.wasm --allow-undefined --lto-O0 --whole-archive /tmp/emscripten_temp/test_0.o -L/home/jay/emsdk/upstream/emscripten/system/local/lib -L/home/jay/emsdk/upstream/emscripten/system/lib -L/home/jay/.emscripten_cache/wasm-obj-pic --no-whole-archive --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --strip-debug --no-gc-sections --export-dynamic --export-all --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush -shared
emcc:DEBUG: emcc step "link" took 0.01 seconds
emcc:DEBUG: LLVM => JS
shared:DEBUG: saving debug copy emcc-0-base.wasm
Fatal: GOT.func entry with no import/export: $emscripten_longjmp_jmpbuf
cache:DEBUG: PID 8731 released multiprocess file lock to Emscripten cache at /home/jay/.emscripten_cache/wasm-obj-pic
Traceback (most recent call last):
  File "/home/jay/emsdk/upstream/emscripten/emcc.py", line 3704, in <module>
    sys.exit(run(sys.argv))
  File "/home/jay/emsdk/upstream/emscripten/emcc.py", line 2235, in run
    final = do_emscripten(final, target + '.mem')
  File "/home/jay/emsdk/upstream/emscripten/emcc.py", line 464, in do_emscripten
    emscripten.run(infile, outfile, memfile)
  File "/home/jay/emsdk/upstream/emscripten/emscripten.py", line 2779, in run
    return temp_files.run_and_clean(lambda: emscripter(
  File "/home/jay/emsdk/upstream/emscripten/tools/tempfiles.py", line 105, in run_and_clean
    return func()
  File "/home/jay/emsdk/upstream/emscripten/emscripten.py", line 2780, in <lambda>
    infile, outfile_obj, memfile, shared.NODE_JS, temp_files, shared.DEBUG)
  File "/home/jay/emsdk/upstream/emscripten/emscripten.py", line 2180, in emscript_wasm_backend
    metadata = finalize_wasm(temp_files, infile, outfile, memfile, DEBUG)
  File "/home/jay/emsdk/upstream/emscripten/emscripten.py", line 2325, in finalize_wasm
    stdout=subprocess.PIPE)
  File "/home/jay/emsdk/upstream/emscripten/tools/shared.py", line 2925, in run_binaryen_command
    ret = run_process(cmd, stdout=stdout).stdout
  File "/home/jay/emsdk/upstream/emscripten/tools/shared.py", line 188, in run_process
    result.check_returncode()
  File "/home/jay/emsdk/upstream/emscripten/tools/shared.py", line 168, in check_returncode
    raise Py2CalledProcessError(returncode=self.returncode, cmd=self.args, output=self.stdout, stderr=self.stderr)
tools.shared.Py2CalledProcessError: Command '['/home/jay/emsdk/upstream/bin/wasm-emscripten-finalize', '--detect-features', '--side-module', '--pass-arg=legalize-js-interface-export-originals', '/tmp/emscripten_temp/test.wasm', '-o', '/tmp/emscripten_temp/test.wasm.o.wasm']' returned non-zero exit status 1
sbc100

sbc100 commented on Dec 3, 2019

@sbc100
Collaborator

Thanks! I've produced this locally now.

added a commit that references this issue on Dec 17, 2019
rohitsaini1995

rohitsaini1995 commented on Dec 18, 2019

@rohitsaini1995

How can I take this fix into my emsdk llvm backend. As I am not getting the fix in updated emsdk version. Do I need to build binaryen from source.

16 remaining items

sbc100

sbc100 commented on Jan 22, 2020

@sbc100
Collaborator

I'm looking at this today. Hopefully we reland the binaryen fix today.

DierkDroth

DierkDroth commented on Jan 23, 2020

@DierkDroth

@sbc100 that would be much appreciated since @jeromelaban (Platform UNO) is waiting to get that fixed in order to deploy to a new build to us...

sbc100

sbc100 commented on Jan 24, 2020

@sbc100
Collaborator

Oh the binaryen side of this fix landed again: WebAssembly/binaryen#2622

Hopefully it will stick this time.

rohitsaini1995

rohitsaini1995 commented on Jan 29, 2020

@rohitsaini1995

Is this WebAssembly/binaryen#2622 available with latest emsdk i.e 1.39.6. Because I tried both emsdk install latest and emsdk install tot-upstream, still the issue occurs.

sbc100

sbc100 commented on Jan 29, 2020

@sbc100
Collaborator

The fix is not in 1.39.6 no. But it should be in tot.

Which version is tot installing for you? You need to run emsdk update-tags before tot gets updated.

You can tell which version of binaryen you have installed by running upstream/bin/wasm-opt --version.

The version should look something like this;

wasm-opt version 90 (version_90-26-g5ca79a71b)

This means binaryen version 90 + 26 additional commits. This fix landed 53 commits after version 90 so if it says less that 53 than you don't have a recent enough version.

We are planning on doing a new emscripten release ASAP that will include this change.

I'm also trying to land a regression test on the emscripten side to prevent this bug from creeping back: #9633

added a commit that references this issue on Feb 4, 2020
stale

stale commented on Jan 30, 2021

@stale

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @kripken@sbc100@jeromelaban@hugoam@rohitsaini1995

    Issue actions

      GOT.func entry with no import/export: $emscripten_longjmp_jmpbuf · Issue #9950 · emscripten-core/emscripten