From 4ffa2aecc119bd70f4765cbb9b911f47dbadd117 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Fri, 1 Nov 2024 12:04:49 -0400 Subject: cmd/internal/obj/wasm: correct return PC for frameless wasmexport wrappers For a wasmexport wrapper, we generate a call to the actual exported Go function, and use the wrapper function's PC 1 as the (fake) return address. This address is not used for returning, which is handled by the Wasm call stack. It is used for stack unwinding, and PC 1 makes it past the prologue and therefore has the right SP delta. But if the function has no arguments and results, the wrapper is frameless, with no prologue, and PC 1 doesn't exist. This causes the unwinder to fail. In this case, we put PC 0, which also has the correct SP delta (0). Fixes #69584. Change-Id: Ic047a6e62100db540b5099cc5a56a1d0f16d58b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/624000 Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI --- src/syscall/js/js_test.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/syscall') diff --git a/src/syscall/js/js_test.go b/src/syscall/js/js_test.go index 76fa442442..9ab913f2ab 100644 --- a/src/syscall/js/js_test.go +++ b/src/syscall/js/js_test.go @@ -75,6 +75,11 @@ func testExport(a int32, b int64) int64 { return <-ch + <-ch } +//go:wasmexport testExport0 +func testExport0() { // no arg or result (see issue 69584) + runtime.GC() +} + var testExportCalled bool func growStack(n int64) { -- cgit v1.3