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/race: no goroutines fatal error when running programs under race detector #24418

Closed
nhooyr opened this issue Mar 16, 2018 · 7 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. RaceDetector
Milestone

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Mar 16, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nhooyr/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/nhooyr/Programming/gopath"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7b/218sfv615xxf_w9ttnpjt0_r0000gn/T/go-build006239443=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Run the following program:

package main

import "runtime"

func main() {
	runtime.Goexit()
}

You'll get:

fatal error: no goroutines (main called runtime.Goexit) - deadlock!

runtime stack:
runtime.throw(0x106c653, 0x36)
	/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:619 +0x81
runtime.checkdead()
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:4148 +0x31b
runtime.mput(0xc42006a000)
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:4519 +0x49
runtime.stopm()
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:1945 +0xba
runtime.findrunnable(0xc420024a00, 0x0)
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:2410 +0x50c
runtime.schedule()
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:2536 +0x13b
runtime.mstart1(0x0)
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:1232 +0x9e
runtime.mstart()
	/usr/local/Cellar/go/1.10/libexec/src/runtime/proc.go:1188 +0x76
exit status 2

If you run with the race detector instead, then the runtime will not complain about there being no goroutines. I think that's because the race detector is running its own goroutines to detect races. I think the runtime should differentiate between them so that the race detector does not hide such serious errors.

@nhooyr nhooyr changed the title running with race detector prevents no goroutines fatal error no goroutines fatal error when running programs under race detector Mar 16, 2018
@davecheney
Copy link
Contributor

davecheney commented Mar 16, 2018 via email

@ALTree ALTree changed the title no goroutines fatal error when running programs under race detector runtime: no goroutines fatal error when running programs under race detector Mar 16, 2018
@andybons andybons changed the title runtime: no goroutines fatal error when running programs under race detector runtime/race: no goroutines fatal error when running programs under race detector Mar 16, 2018
@andybons
Copy link
Member

/cc @dvyukov

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 16, 2018
@andybons andybons added this to the Go1.11 milestone Mar 16, 2018
@dvyukov
Copy link
Member

dvyukov commented Mar 19, 2018

The same happens if you import "C", right?

@odeke-em
Copy link
Member

odeke-em commented Mar 28, 2018

I think this might be sort of related to an issue that I am going to work on in the next couple of days #21576. I started working on it with what seemed like a seemingly straightforward fix, but alas when cgo is enabled seems like a signal.Notify like loop is started and it won't catch deadlocks either. /cc @ianlancetaylor

@dvyukov
Copy link
Member

dvyukov commented Mar 28, 2018

We can fix cgo, we can fix signal.Notify, but then a program imports some package that starts a single background goroutine and we have the same problem. The buitin deadlock detector is really for the simplest handbook cases.

@nhooyr
Copy link
Contributor Author

nhooyr commented Mar 28, 2018

There is a difference between a background goroutine that could actually be doing something vs one that is deadlocked. If deadlocked, its a definite bug and we should detect it if possible.

@dvyukov
Copy link
Member

dvyukov commented Apr 3, 2018

Duplicate of #20588

@dvyukov dvyukov marked this as a duplicate of #20588 Apr 3, 2018
@dvyukov dvyukov closed this as completed Apr 3, 2018
@golang golang locked and limited conversation to collaborators Apr 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. RaceDetector
Projects
None yet
Development

No branches or pull requests

6 participants