Skip to content

wasm-opt crashes with segmentation fault on big project #7570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gggrafff opened this issue May 5, 2025 · 1 comment
Open

wasm-opt crashes with segmentation fault on big project #7570

gggrafff opened this issue May 5, 2025 · 1 comment

Comments

@gggrafff
Copy link

gggrafff commented May 5, 2025

Hello!
We found that wasm-opt sometimes crashes with the error `Segmentation fault (core dumped)'.

What can help with debugging:

  • We use wasm-opt together with tinygo.
  • The error appears on a large project, if we remove any parts from this project in order to reduce the project, the error disappears. We couldn't make a minimal example to reproduce, and our project is proprietary and I can't give it.
  • The error is not reproducible on mac, valid working configuration:
% tinygo version
tinygo version 0.37.0 darwin/amd64 (using go version go1.22.12 and LLVM version 19.1.2)
% /usr/local/bin/wasm-opt --version
wasm-opt version 117
  • The error is consistently reproduced on linux on different hardware, with different operating systems, different versions of wasm-opt (tested 116 and 123).
  • The error is reproduced only on your builds (https://github.com/WebAssembly/binaryen/releases). When I downloaded the project and built it myself, the error did not reproduce.

Own build, does not fall:

$ rm /tmp/tinygo3733807473/main.wasmopt
$ ls /tmp/tinygo3733807473/
main  main.o
$ ./build/bin/wasm-opt --version
wasm-opt version 123 (version_123)
$ ./build/bin/wasm-opt -O2 -g /tmp/tinygo3733807473/main --output /tmp/tinygo3733807473/main.wasmopt
$ ls /tmp/tinygo3733807473/
main  main.o  main.wasmopt

Downloaded build of the same version crashes:

$ rm /tmp/tinygo3733807473/main.wasmopt
$ ls /tmp/tinygo3733807473/
main  main.o
$ /opt/binaryen-version_123/bin/wasm-opt --version
wasm-opt version 123 (version_123)
$ /opt/binaryen-version_123/bin/wasm-opt -O2 -g /tmp/tinygo3733807473/main --output /tmp/tinygo3733807473/main.wasmopt
Segmentation fault (core dumped)

Thank you. Write to issue thread if you need more information.

@kripken
Copy link
Member

kripken commented May 5, 2025

Some ideas: Perhaps try to build locally with the same cmake as releases use,

- name: cmake
run: |
./alpine.sh cmake . -G Ninja -DCMAKE_CXX_FLAGS="-static" -DCMAKE_C_FLAGS="-static" -DCMAKE_BUILD_TYPE=Release -DBUILD_STATIC_LIB=ON -DBUILD_MIMALLOC=ON -DCMAKE_INSTALL_PREFIX=install

If that doesn't work, try with docker to fully reproduce the CI build.

Hopefully one of those works, and you can make a debug build that also shows the issue, which could give us a full stack trace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants