brson / wasm-opt-rs

Rust bindings for Binaryen's wasm-opt
Apache License 2.0
61 stars 10 forks source link

[Bug] Got segmentation fault when use #140

Closed starua closed 1 year ago

starua commented 1 year ago

Using parameter: -O4 -g Core Dump File: core.wasm-opt.1000.ec82f6ee86274bd3bad775dbfdf1ccb1.19430.1679967785000000.zip My source file: ScreepsBot_bg.wasm.zip

brson commented 1 year ago

Thanks for the report. Looking into it today.

brson commented 1 year ago

I have not been able to reproduce the segfault locally, either with these bindings or the upstream wasm-opt from https://github.com/WebAssembly/binaryen

From the output of file on the coredump I see this looks like it was invoked by wasm-pack:

file ../wasm-opt-bug/core.wasm-opt.1000.ec82f6ee86274bd3bad775dbfdf1ccb1.19430.1679967785000000
../wasm-opt-bug/core.wasm-opt.1000.ec82f6ee86274bd3bad775dbfdf1ccb1.19430.1679967785000000: ELF 64-bit LSB core file, x86-64, version 1 (SYSV), SVR4-style, from '/home/ttxs/.cache/.wasm-pack/wasm-opt-4d7a65327e9363b7/wasm-opt /home/ttxs/Docu', real uid: 1000, effective uid: 1000, real gid: 1000, effective gid: 1000, execfn: '/home/ttxs/.cache/.wasm-pack/wasm-opt-4d7a65327e9363b7/wasm-opt', platform: 'x86_64'

I think this means that wasm-pack is using its own version of wasm-opt, which I think it downloads from https://github.com/WebAssembly/binaryen, not from the rust bindings in this repo.

If that is the case, then it looks like the most recent wasm-pack is using wasm-opt 111, so upgrading to wasm-opt 112 might help. That can be done by downloading from the upstream https://github.com/WebAssembly/binaryen, or by installing from this project with cargo install wasm-opt.

I don't know offhand how to tell wasm-pack to use a specific wasm-opt binary, but it might automatically pick it up if wasm-opt is located in one of the directories in the $PATH environment variable.

brson commented 1 year ago

I also downloaded several past binary releases of wasm-opt for x86-64 linux from https://github.com/WebAssembly/binaryen/releases and ran them like

binaryen-version_112/bin/wasm-opt ScreepsBot_bg.wasm -O4 -g -o - > /dev/null

and have not seen a segfault.

starua commented 1 year ago

This is the binary file i'm using: wasm-opt.zip I tested it again and the problem continue.

About the version, it's wasm-opt version_90, and i believe this is the version that auto download by wasm-pack.

starua commented 1 year ago

I try the version that installed by cargo install wasm-opt and the problem is gone, thank.