Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: deadlock detection does not work properly in js/wasm #70869

Open
Zxilly opened this issue Dec 16, 2024 · 3 comments
Open

runtime: deadlock detection does not work properly in js/wasm #70869

Zxilly opened this issue Dec 16, 2024 · 3 comments
Assignees
Labels
arch-wasm WebAssembly issues compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@Zxilly
Copy link
Member

Zxilly commented Dec 16, 2024

Go version

go version go1.23.3 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\zxilly\AppData\Local\go-build
set GOENV=C:\Users\zxilly\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\zxilly\go\pkg\mod
set GONOPROXY=1
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\zxilly\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23.3
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\zxilly\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\zxilly\AppData\Local\Temp\go-build192904976=/tmp/go-build -gno-record-gcc-switches

What did you do?

Compile and run following code

package main

func main() {
	select {}
}

What did you see happen?

This will lead to

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [select (no cases)]:
main.main()
        T:/wasm/test.go:4 +0xf

on windows/amd64.

However, on js/wasm build, it will lead to

PS T:\wasm> node "C:\Program Files\Go\misc\wasm\wasm_exec_node.js" t.wasm
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x0 addr=0x0 pc=0x0]

goroutine 5 [running]:
panic({0xbc20, 0xc2280})
        C:/Program Files/Go/src/runtime/panic.go:804 +0x23
runtime.panicmem(...)
        C:/Program Files/Go/src/runtime/panic.go:262
runtime.sigpanic()
        C:/Program Files/Go/src/runtime/os_wasm.go:30 +0xb
runtime.handleEvent()
        C:/Program Files/Go/src/runtime/lock_js.go:289 +0x14
runtime.goexit({})
        C:/Program Files/Go/src/runtime/asm_wasm.s:434 +0x1

What did you expect to see?

Similiar output on wasm platform

@Jorropo Jorropo added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues labels Dec 16, 2024
@Jorropo Jorropo added this to the Backlog milestone Dec 16, 2024
@Jorropo Jorropo changed the title wasm: deadlock detection does not work properly in wasm runtime: deadlock detection does not work properly in wasm Dec 16, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 16, 2024
@mknyszek
Copy link
Contributor

CC @golang/runtime

@mknyszek mknyszek self-assigned this Dec 18, 2024
@cherrymui cherrymui changed the title runtime: deadlock detection does not work properly in wasm runtime: deadlock detection does not work properly in js/wasm Dec 19, 2024
@cherrymui
Copy link
Member

This is specific to js/wasm, probably related to how handleEvent is implemented. It works as expected on wasip1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Development

No branches or pull requests

6 participants