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: cgo program with select {} hangs #25538

Closed
alexbrainman opened this issue May 24, 2018 · 3 comments
Closed

runtime: cgo program with select {} hangs #25538

alexbrainman opened this issue May 24, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@alexbrainman
Copy link
Member

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

@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels May 24, 2018
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone May 24, 2018
@ianlancetaylor
Copy link
Contributor

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.

@aclements
Copy link
Member

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.

@rsc
Copy link
Contributor

rsc commented May 24, 2018

I agree with Austin. This program might just be a shell to let C threads execute. There's no way to know.

@rsc rsc closed this as completed May 24, 2018
@golang golang locked and limited conversation to collaborators May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants