]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/obj/wasm, runtime: detect wasmexport call before runtime initialization
authorCherry Mui <cherryyz@google.com>
Thu, 16 Jan 2025 18:56:15 +0000 (13:56 -0500)
committerCherry Mui <cherryyz@google.com>
Thu, 16 Jan 2025 20:14:23 +0000 (12:14 -0800)
commit0b632d26b99e3924aea14574e422065e13f2a1c5
tree90299ca724f577b5d3548e02bb2a3720e9f67b8c
parent6a4effa08ba5c7b182d319a2a8ddd782274c2f74
cmd/internal/obj/wasm, runtime: detect wasmexport call before runtime initialization

If a wasmexport function is called from the host before
initializing the Go Wasm module, currently it will likely fail
with a bounds error, because the uninitialized SP is 0, and any
SP decrement will make it out of bounds.

As at least some Wasm runtime doesn't call _initialize by default,
This error can be common. And the bounds error looks confusing to
the users. Therefore, we detect this case and emit a clearer error.

Fixes #71240.
Updates #65199.

Change-Id: I107095f08c76cdceb7781ab0304218eab7029ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/643115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/cmd/internal/obj/wasm/wasmobj.go
src/cmd/link/internal/wasm/asm.go
src/runtime/asm_wasm.s
src/runtime/sys_wasm.go