wasm callback loop handling: TypeError: "target
argument of Reflect.get must be an object, got (void 0)"
#28448
Labels
target
argument of Reflect.get must be an object, got (void 0)"
#28448
What version of Go are you using (
go version
)?go version go1.11.1 linux/amd64
Does this issue reproduce with the latest release?
This is the latest (right?)
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ivo/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ivo/m3r/projects/WASMBug"
GOPROXY=""
GORACE=""
GOROOT="/opt/go1.11.1"
GOTMPDIR=""
GOTOOLDIR="/opt/go1.11.1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build637835953=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Play with wasm. Specifically, with registering callbacks. The most simple setup already results in a panic after the first callback.
main.go:
index.html
What did you expect to see?
Hello World on the console (which is shown) without a crash.
What did you see instead?
On firefox (but similar stacktraces on chromium)
I've attempted to debug this myself. It seems that in go/src/syscall/js/callback.js,
cb := pendingCallbacks.Call("shift")
returns a (ref) Value 0 (not
Undefined()
) if the array is empty. If I add multiple similar shifts, I keep getting a 0 value:Global().Get("console").Call("info", "cb is " + strconv.FormatUint(uint64(cb.ref ), 10))
It almost feels asif
Call("shift")
on an empty array gives some 0 value in stead of undefined like it does in js.The
id := uint32(cb.Get("id").Int())
a few lines later is what's eventually resulting in the panic "call of Value.Int on object wasm_exec.js:47:6"I can't imagine such a trivial example not working so I must be doing something wrong but I'm unable to find it.
The text was updated successfully, but these errors were encountered: