runtime: cgo program with select {} hangs #25538
Closed
Labels
Milestone
Comments
The deadlock detector doesn't work for programs that use cgo, and never has. I would call this a bug, but it's low priority and hard to fix. |
Is this even possible to fix? The C code could have started threads that the Go runtime isn't aware of, so the process could still be making progress even if no goroutines are runnable and there are no calls from Go into C. |
I agree with Austin. This program might just be a shell to let C threads execute. There's no way to know. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?go version devel +65c365b Wed May 23 23:51:30 2018 +0000 linux/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="/home/a/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/a"
GORACE=""
GOROOT="/home/a/go"
GOTMPDIR=""
GOTOOLDIR="/home/a/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build476325891=/tmp/go-build -gno-record-gcc-switches"
What did you do?
$ cat main.go
package main
import "C"
func main() {
select {}
}
$ go build -o a && ./a
What did you expect to see?
fatal error: all goroutines are asleep - deadlock!
...
similar to what program above does without import "C".
What did you see instead?
My program hangs.
This was discovered #6751 (comment) by @billziss-gh in the search for solution for issue #6751.
/cc @aclements and @ianlancetaylor
I am not sure if this is a bug or not, so looking for advice.
Alex
The text was updated successfully, but these errors were encountered: