wasm3 / node-wasm-trace

Instruments wasm files and traces execution
MIT License
31 stars 5 forks source link

Failing inside Binaryen during execution #5

Open RReverser opened 3 years ago

RReverser commented 3 years ago

When trying to execute arbitrary WASI program compiled from C / Rust, it throws an error somewhere inside Binaryen:

> npx wasm-trace -E temp.wasm                                                                    
[tracer] Instrumenting and optimizing...
[tracer] Running WASI...
[TypeError: WebAssembly.instantiate(): Import #0 module="wasi_snapshot_preview1" error: module is not an object or function]
[TypeError: WebAssembly.instantiate(): Import #0 module="wasi_snapshot_preview1" error: module is not an object or function]

C:\Users\rreverser\AppData\Local\npm-cache\_npx\dd4973ce67a8a99d\node_modules\binaryen\index.js:7
if(m)n=__dirname+"/",ja=function(b,d){var g=p(b);if(g)return d?g:g.toString();ma||(ma=require("fs"));na||(na=require("path"));b=na.normalize(b);return ma.readFileSync(b,d?null:"utf8")},la=function(b){b=ja(b,!0);b.buffer||(b=new Uint8Array(b));assert(b.buffer);return b},1<process.argv.length&&(ba=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(b){if(!(b instanceof oa))throw b;}),process.on("unhandledRejection",q),da=function(b){process.exit(b)},a.inspect=

                                                                                                                                      ^        
abort(TypeError: WebAssembly.instantiate(): Import #0 module="wasi_snapshot_preview1" error: module is not an object or function). Build with -s ASSERTIONS=1 for more info.
(Use `node --trace-uncaught ...` to show where the exception was thrown)
npm ERR! code 7
npm ERR! path C:\src\v8.dev
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c wasm-trace -E temp.wasm

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rreverser\AppData\Local\npm-cache\_logs\2021-02-19T12_13_12_289Z-debug.log
RReverser commented 3 years ago

I've tried to disable optimizations, but that doesn't seem to make a difference.