Open ajwerner opened 1 month ago
@johanbrandhorst this one is likely to interest you.
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
CC @golang/wasm @cherrymui
Change https://go.dev/cl/624000 mentions this issue: cmd/internal/obj/wasm: correct return PC for frameless wasmexport wrappers
Go version
go version devel go1.24-c208b91 Fri Sep 20 13:54:44 2024 +0000 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I attempted to use the new functionality introduced in https://github.com/golang/go/issues/65199 which allows for greatly reducing the cost to call a go function compiled to webassembly. At first it worked great, but then I noticed it failing whenever it needed to grow the stack. I also notice that if you just call
runtime.GC
, similar bad stuff happens.Consider the following program:
You can compile this program like:
GOOS=wasip1 GOARCH=wasm gotip build -buildmode=c-shared -o test.wasm ./test_wasm.go
Then you can have a runner program like:
which can be run with
go run ./main.go
go run ./main.go
What did you see happen?
I saw the runtime crash inside wasm, see output. I'll note that in my initial issue, I was not calling
runtime.GC
, I just happened to see similar failures inside things likegrowstack
and background gc assist. I also noticed that if I add a return value to the entrypoint function, the problems seem to go away.What did you expect to see?
I expected to not see it crash.