Open Celebraty opened 1 year ago
Thanks for the bug report!
I start a go routine, the go routine call the wasm function, then i stop the wasm instance, then it panic.
EMSCRIPTEN_KEEPALIVE char* loop(int i) { while(true) { printf("%d\n", i); } return NULL; }
go func() { _, err := loop(int32(i)) fmt.Printf("err=%v\n", err) }() time.Sleep(time.Second * 1) wasmStruct.instance.Close()
fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x2 addr=0x298514c2c pc=0x101720a30]
runtime stack: runtime.throw({0x1004da2e0?, 0x298000000?}) /go1.18.4/src/runtime/panic.go:992 +0x50 runtime.sigpanic() /go1.18.4/src/runtime/signal_unix.go:802 +0x1e8
goroutine 34 [syscall]: runtime.cgocall(0x1004ce1a4, 0x14000418548) /go1.18.4/src/runtime/cgocall.go:157 +0x54 fp=0x14000418510 sp=0x140004184d0 pc=0x10034ff94 github.com/wasmerio/wasmer-go/wasmer._Cfunc_wasm_func_call(0x6000003ccdc0, 0x14000012530, 0x14000012520) _cgo_gotypes.go:1235 +0x3c fp=0x14000418540 sp=0x14000418510 pc=0x1004176dc github.com/wasmerio/wasmer-go/wasmer.(Function).Native.func1.5(0x14000012530?, 0x0?, 0x1400001e150?) /pkg/mod/github.com/wasmerio/wasmer-go@v1.0.4/wasmer/function.go:317 +0xcc fp=0x14000418590 sp=0x14000418540 pc=0x10041d6cc github.com/wasmerio/wasmer-go/wasmer.(Function).Native.func1({0x14000012510, 0x1, 0x1004d1041?}) /pkg/mod/github.com/wasmerio/wasmer-go@v1.0.4/wasmer/function.go:317 +0x2e8 fp=0x14000418740 sp=0x14000418590 pc=0x10041d1e8 script_myself/wasmer.ExecuteLoop.func1() loop.go:21 +0xb4 fp=0x140004187d0 sp=0x14000418740 pc=0x1004cd674 runtime.goexit() /go1.18.4/src/runtime/asm_arm64.s:1263 +0x4 fp=0x140004187d0 sp=0x140004187d0 pc=0x1003ac844 created by script_myself/wasmer.ExecuteLoop loop.go:20 +0x70
goroutine 1 [sleep]: time.Sleep(0x12a05f200) /go1.18.4/src/runtime/time.go:194 +0x11c
exit status 2
### Expected behavior the NativeFunction loop stop print. ### Actual behavior panic
Thanks for the bug report!
Describe the bug
I start a go routine, the go routine call the wasm function, then i stop the wasm instance, then it panic.
Steps to reproduce
runtime stack: runtime.throw({0x1004da2e0?, 0x298000000?}) /go1.18.4/src/runtime/panic.go:992 +0x50 runtime.sigpanic() /go1.18.4/src/runtime/signal_unix.go:802 +0x1e8
goroutine 34 [syscall]: runtime.cgocall(0x1004ce1a4, 0x14000418548) /go1.18.4/src/runtime/cgocall.go:157 +0x54 fp=0x14000418510 sp=0x140004184d0 pc=0x10034ff94 github.com/wasmerio/wasmer-go/wasmer._Cfunc_wasm_func_call(0x6000003ccdc0, 0x14000012530, 0x14000012520) _cgo_gotypes.go:1235 +0x3c fp=0x14000418540 sp=0x14000418510 pc=0x1004176dc github.com/wasmerio/wasmer-go/wasmer.(Function).Native.func1.5(0x14000012530?, 0x0?, 0x1400001e150?) /pkg/mod/github.com/wasmerio/wasmer-go@v1.0.4/wasmer/function.go:317 +0xcc fp=0x14000418590 sp=0x14000418540 pc=0x10041d6cc github.com/wasmerio/wasmer-go/wasmer.(Function).Native.func1({0x14000012510, 0x1, 0x1004d1041?}) /pkg/mod/github.com/wasmerio/wasmer-go@v1.0.4/wasmer/function.go:317 +0x2e8 fp=0x14000418740 sp=0x14000418590 pc=0x10041d1e8 script_myself/wasmer.ExecuteLoop.func1() loop.go:21 +0xb4 fp=0x140004187d0 sp=0x14000418740 pc=0x1004cd674 runtime.goexit() /go1.18.4/src/runtime/asm_arm64.s:1263 +0x4 fp=0x140004187d0 sp=0x140004187d0 pc=0x1003ac844 created by script_myself/wasmer.ExecuteLoop loop.go:20 +0x70
goroutine 1 [sleep]: time.Sleep(0x12a05f200) /go1.18.4/src/runtime/time.go:194 +0x11c
exit status 2