wazero: JIT: Exception 0xc0000005 0x8 0x0 0x0
I’m testing some code with Wazero, and I notice one odd crash, that I’m not sure if it’s either my code (which is Zig) or Wazero. That is strange from previous errors, because it’s one “Exception 0xc0000005 0x8 0x0 0x0”. It’s not an panic or something from testing.Error(err).
I’m using Windows/amd64.
The log is:
go test -tags wasi,km,zig -v -bench=. -benchmem -benchtime=5s -cpu 1
=== RUN TestEncodeObjectAPI
Exception 0xc0000005 0x8 0x0 0x0
PC=0x0
github.com/tetratelabs/wazero/internal/wasm/jit.(*callEngine).execWasmFunction(0xc00074a240, {0x5dd008, 0xc00009e140}, 0xc000952e70, 0xc000952cf0)
Z:/GOPATH/pkg/mod/github.com/tetratelabs/wazero@v0.0.0-20220430041858-abd1c79f3335/internal/wasm/jit/engine.go:699 +0x185 fp=0xc00095dbb8 sp=0xc00095dae0 pc=0x4d5305
github.com/tetratelabs/wazero/internal/wasm/jit.(*moduleEngine).Call(0xc000954030?, {0x5dd008, 0xc00009e140}, 0xc000952e70, 0xc000494dd0, {0xc000954030, 0x1, 0x1})
Z:/GOPATH/pkg/mod/github.com/tetratelabs/wazero@v0.0.0-20220430041858-abd1c79f3335/internal/wasm/jit/engine.go:582 +0x48f fp=0xc00095dcb8 sp=0xc00095dbb8 pc=0x4d4b2f
github.com/tetratelabs/wazero/internal/wasm.(*FunctionInstance).Call(0x53bca0?, {0x5dd008?, 0xc00009e140?}, {0xc000954030?, 0xc000022270?, 0x0?})
Z:/GOPATH/pkg/mod/github.com/tetratelabs/wazero@v0.0.0-20220430041858-abd1c79f3335/internal/wasm/call_context.go:164 +0x63 fp=0xc00095dd08 sp=0xc00095dcb8 pc=0x4901c3
benchmark%2ekarmem%2eorg.(*Wasm).Run(...)
X:/karmem/benchmark/main_wasi_test.go:289
benchmark%2ekarmem%2eorg.TestEncodeObjectAPI(0xc000061040)
X:/karmem/benchmark/main_wasi_test.go:113 +0x1f6 fp=0xc00095df70 sp=0xc00095dd08 pc=0x50d556
testing.tRunner(0xc000061040, 0x58dce8)
C:/Program Files/Go/src/testing/testing.go:1439 +0x102 fp=0xc00095dfc0 sp=0xc00095df70 pc=0x3e3482
testing.(*T).Run.func1()
C:/Program Files/Go/src/testing/testing.go:1486 +0x2a fp=0xc00095dfe0 sp=0xc00095dfc0 pc=0x3e432a
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc00095dfe8 sp=0xc00095dfe0 pc=0x3587a1
created by testing.(*T).Run
C:/Program Files/Go/src/testing/testing.go:1486 +0x35f
goroutine 1 [chan receive]:
testing.(*T).Run(0xc000060ea0, {0x57e4e0?, 0x35af53?}, 0x58dce8)
C:/Program Files/Go/src/testing/testing.go:1487 +0x37a
testing.runTests.func1(0xc000020090?)
C:/Program Files/Go/src/testing/testing.go:1839 +0x6e
testing.tRunner(0xc000060ea0, 0xc0000c3cd8)
C:/Program Files/Go/src/testing/testing.go:1439 +0x102
testing.runTests(0xc000094320?, {0x72cd40, 0x1, 0x1}, {0x26848cc0598?, 0x40?, 0x738f20?})
C:/Program Files/Go/src/testing/testing.go:1837 +0x457
testing.(*M).Run(0xc000094320)
C:/Program Files/Go/src/testing/testing.go:1719 +0x5d9
main.main()
_testmain.go:57 +0x1aa
rax 0x20
rbx 0x110000
rcx 0xc000494270
rdi 0x1100000012
rsi 0xc0002de820
rbp 0xc00095dba8
rsp 0xc00095dad8
r8 0x23280
r9 0x8
r10 0x90
r11 0x0
r14 0xc000966600
r15 0xc004a90000
rip 0x0
rflags 0x10202
cs 0x33
fs 0x53
gs 0x2b
exit status 2
That issue is ONLY affecst JIT, so I think it’s an Wazero issue. The biggest issue is that it crashes the entire program and it’s not possible to recover.
Change:
wazero.NewRuntimeConfigJIT().WithFinishedFeatures()
To:
wazero.NewRuntimeConfigInterpreter().WithFinishedFeatures()
Runs the tests without issue:
=== RUN TestEncodeObjectAPI
--- PASS: TestEncodeObjectAPI (17.07s)
Also, it’s ONLY affects WASM compiled with zig build install -Dtarget="wasm32-wasi" -Drelease-safe, so if you compile as debug zig build install -Dtarget="wasm32-wasi" it will run. A lot slower, but runs. The debug have more bounds checks and so on. So, maybe there’s something in my code that is actually crashing the runtime, crashing at one unrecoverable point.
I’ll share the source-code soon.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 27 (25 by maintainers)
I tested it on MacOS and Windows, and the first issue (Zig) is fixed. 🥳
@inkeliz thank you so much for reporting these issues! You indeed helped us a lot! 👍
let me implement it and make sure the test passes
so the second compilation error stuff https://github.com/tetratelabs/wazero/pull/584 will solve it.
ok i will defer the investigation on this until finish SIMD (hence closes #484) as that’s our priority… but yeah this must be resolved so I promise in a week or so!