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: fatal error: all goroutines are asleep - deadlock! #22424

Closed
AnyCPU opened this issue Oct 24, 2017 · 4 comments
Closed

runtime: fatal error: all goroutines are asleep - deadlock! #22424

AnyCPU opened this issue Oct 24, 2017 · 4 comments

Comments

@AnyCPU
Copy link

AnyCPU commented Oct 24, 2017

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

go version go1.9.2rc2 windows/amd64

Does this issue reproduce with the latest release?

Yes: 1.9.1

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

Windows Server 2012, version 6.2, Build 9200
This is a guest OS under VMware virtualization, vSockets (dgram & stream) installed (checked via https://play.golang.org/p/5HEevQM2cL)

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\proj\_nda_\_nda_
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

the main function starts an one goroutine for logging (implemented via channels) and then does db.Ping() on the postgresql's connection. Then the other code runs.

What did you expect to see?

Something like that:
before pinging
Connecting to db ...
After
Connected

What did you see instead?

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0xc95080, 0x72, 0x0)
        C:/Go/src/runtime/netpoll.go:173 +0x5e
internal/poll.(*pollDesc).wait(0xc04208c5d8, 0x72, 0x8a5200, 0x0, 0x0)
        C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xb5
internal/poll.(*ioSrv).ExecIO(0x8c43c0, 0xc04208c498, 0x75c070, 0xc0, 0xc04208c5
80, 0x1)
        C:/Go/src/internal/poll/fd_windows.go:205 +0x13a
internal/poll.(*FD).Read(0xc04208c480, 0xc0420de000, 0x1000, 0x1000, 0x0, 0x0, 0
x0)
        C:/Go/src/internal/poll/fd_windows.go:458 +0x266
net.(*netFD).Read(0xc04208c480, 0xc0420de000, 0x1000, 0x1000, 0x0, 0x0, 0xc04205
f2f8)
        C:/Go/src/net/fd_windows.go:151 +0x59
net.(*conn).Read(0xc042004038, 0xc0420de000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        C:/Go/src/net/net.go:176 +0x74
bufio.(*Reader).Read(0xc042038180, 0xc0420dc020, 0x5, 0x200, 0x0, 0x0, 0x1000501
42040500)
        C:/Go/src/bufio/bufio.go:213 +0x312
io.ReadAtLeast(0x8a67a0, 0xc042038180, 0xc0420dc020, 0x5, 0x200, 0x5, 0x8, 0x18,
 0xc042003940)
        C:/Go/src/io/io.go:309 +0x8d
io.ReadFull(0x8a67a0, 0xc042038180, 0xc0420dc020, 0x5, 0x200, 0x1ff, 0x5e, 0x0)
        C:/Go/src/io/io.go:327 +0x5f
_nda_/vendor/github.com/lib/pq.(*conn).recvMessage(0xc0420dc000, 0xc042003940, 0x
1ff, 0x5e, 0x0)
        _nda_/vendor/github.com/lib/pq/conn.go:947 +0x155
_nda_/vendor/github.com/lib/pq.(*conn).recv(0xc0420dc000, 0xc04205f588, 0x0)
        _nda_/vendor/github.com/lib/pq/conn.go:977 +0x8c
_nda_/vendor/github.com/lib/pq.(*conn).startup(0xc0420dc000, 0xc0420768d0)
        _nda_/vendor/github.com/lib/pq/conn.go:1099 +0xa0e
_nda_/vendor/github.com/lib/pq.DialOpen(0x8a97a0, 0x8e2b98, 0xc0420100f0, 0x43, 0
x0, 0x0, 0x0, 0x0)
        _nda_/vendor/github.com/lib/pq/conn.go:344 +0x69e
_nda_/vendor/github.com/lib/pq.Open(0xc0420100f0, 0x43, 0x0, 0x0, 0xc042008600, 0
x0)
        _nda_/vendor/github.com/lib/pq/conn.go:251 +0x54
_nda_/vendor/github.com/lib/pq.(*Driver).Open(0x8e2b98, 0xc0420100f0, 0x43, 0xc04
2008600, 0x16, 0xc000000073, 0x4c39d8)
        _nda_/vendor/github.com/lib/pq/conn.go:45 +0x3c
database/sql.(*DB).conn(0xc0420441e0, 0x8aaba0, 0xc04200a3d8, 0x1, 0xc04201e000,
 0xc0420780f0, 0xc0420768a0)
        C:/Go/src/database/sql/sql.go:999 +0x137
database/sql.(*DB).PingContext(0xc0420441e0, 0x8aaba0, 0xc04200a3d8, 0xc04205faf
8, 0xc042044208)
        C:/Go/src/database/sql/sql.go:631 +0x98
database/sql.(*DB).Ping(0xc0420441e0, 0x2, 0xc0420441e0)
        C:/Go/src/database/sql/sql.go:649 +0x4a
_nda_/app.(*App).Do(0xc042034240, 0x0, 0x0)


goroutine 5 [chan receive]:
_nda_.(*Log).do.func1(0xc042003220)
        _nda_/log.go:87 +0x12b
created by _nda_.(*Log).do
        _nda_/log.go:82 +0x46

goroutine 6 [chan receive]:
database/sql.(*DB).connectionOpener(0xc0420441e0)
        C:/Go/src/database/sql/sql.go:871 +0x5a
created by database/sql.Open
        C:/Go/src/database/sql/sql.go:609 +0x1f5

Also I saw suggestions from #22149 . I updated Go, but it did not help.

The code runs well, but sometimes it crashes whenever it wants.
Running under admin rights does not help too.

@ianlancetaylor ianlancetaylor changed the title fatal error: all goroutines are asleep - deadlock! runtime: fatal error: all goroutines are asleep - deadlock! Oct 24, 2017
@ianlancetaylor
Copy link
Contributor

Can we see your code?

Note that it's possible for a program to deadlock because of a bug in the program that is not a bug in Go.

@alexbrainman
Copy link
Member

Maybe this is similar to #22394.

Alex

@AnyCPU
Copy link
Author

AnyCPU commented Oct 25, 2017

@ianlancetaylor I will prepare an example.
I understand your point. I checked code a lot of times. It can run successfully 20 times in a row, it can fail 10 times in a row, it can run successfully for a one week. The installation is deployed on a private network and all the devop tasks are controlled.

@AnyCPU
Copy link
Author

AnyCPU commented Nov 6, 2017

Maybe this is similar to #22394.

Yes, it is true.
I confirm this bug was fixed in Go 1.9.2.

@golang golang locked and limited conversation to collaborators Nov 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants