wasmerio / wasmer-go

🐹🕸️ WebAssembly runtime for Go

Home Page:https://pkg.go.dev/github.com/wasmerio/wasmer-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loop call wasmer instance export func will occur panic

tianyu0901 opened this issue · comments

Work env

  1. OS: Ubuntu 22.04.1 LTS \n \l
  2. go version: go version go1.17.6 linux/amd64

I also use the newer version golang, but the same panic will occur.

Code

    //******
sum, err := instance.Exports.GetFunction("sum")
if err != nil {
	panic(fmt.Sprintln("Failed to get the `add_one` function:", err))
}

for i := 0; i < 10000*10; i++ {
	_, err = sum(1, 2)
	if err != nil {
		panic(fmt.Sprintln("Failed to call the `add_one` function:", err))
	}
}

Panic msg

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7f2c5d9393df pc=0x7f2c5d9393df]

runtime stack:
runtime.throw({0x4b5e07, 0x0})
/home/m/soft/go1.7.6/src/runtime/panic.go:1198 +0x71
runtime.sigpanic()
/home/m/soft/go1.7.6/src/runtime/signal_unix.go:719 +0x396

goroutine 1 [syscall]:
runtime.cgocall(0x4926c0, 0xc000048bd8)
/home/m/soft/go1.7.6/src/runtime/cgocall.go:156 +0x5c fp=0xc000048bb0 sp=0xc000048b78 pc=0x40a31c
github.com/wasmerio/wasmer-go/wasmer._Cfunc_wasm_func_call(0x21382c0, 0xc000012190, 0xc000012180)
_cgo_gotypes.go:1239 +0x4d fp=0xc000048bd8 sp=0xc000048bb0 pc=0x489e2d
github.com/wasmerio/wasmer-go/wasmer.(*Function).Native.func1.5(0xc000012190, 0x2, 0xc00001a260)
/home/m/code/golang/pkg/mod/github.com/wasmerio/wasmer-go@v1.0.4/wasmer/function.go:317 +0xa7 fp=0xc000048c20 sp=0xc000048bd8 pc=0x48d567
github.com/wasmerio/wasmer-go/wasmer.(*Function).Native.func1({0xc00002a180, 0x2, 0xc000082340})
/home/m/code/golang/pkg/mod/github.com/wasmerio/wasmer-go@v1.0.4/wasmer/function.go:317 +0x40a fp=0xc000048dd0 sp=0xc000048c20 pc=0x48cf8a
main.main()
/home/m/code/gomod/wasmer-test/main.go:42 +0x222 fp=0xc000048f80 sp=0xc000048dd0 pc=0x491e62
runtime.main()
/home/m/soft/go1.7.6/src/runtime/proc.go:255 +0x227 fp=0xc000048fe0 sp=0xc000048f80 pc=0x43ac27
runtime.goexit()
/home/m/soft/go1.7.6/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000048fe8 sp=0xc000048fe0 pc=0x463dc1