Skip to content

testing: timeouts prevent deadlock detection from working #69188

@myaaaaaaaaa

Description

@myaaaaaaaaa

Go version

go version go1.23.0 linux/amd64

Output of go env in your module/workspace:

Click to expand
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='~/.cache/go-build'
GOENV='~/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='~/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='~/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='~/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3043789877=/tmp/go-build -gno-record-gcc-switches'

What did you do?

package main

func main() {
	select {}
}



package main_test

import "testing"

func TestDeadlock(t *testing.T) {
	select {}
}

What did you see happen?

$ go run main.go
fatal error: all goroutines are asleep - deadlock!
...


$ go test -timeout 0
fatal error: all goroutines are asleep - deadlock!
...


$ go test -timeout 1s    # note that the default is 10m
panic: test timed out after 1s
	running tests:
		TestDeadlock (1s)
...

What did you expect to see?

 $ go run main.go
 fatal error: all goroutines are asleep - deadlock!
 ...
 
 
 $ go test -timeout 0
 fatal error: all goroutines are asleep - deadlock!
 ...
 
 
 $ go test -timeout 1s    # note that the default is 10m
-panic: test timed out after 1s
-	running tests:
-		TestDeadlock (1s)
+fatal error: all goroutines are asleep - deadlock!
 ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions