The code at https://play.golang.org/p/9ZdPVvwyaYK 
<https://play.golang.org/p/JRSEPU3Uf17>

should not deadlock. But it reports:

fatal error: all goroutines are asleep - deadlock!

But if you look at the stack traces, you see multiple routines (sampled) like:

goroutine 1 [sleep]:
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:307
time.Sleep(0x3e8, 0x0)
        /usr/local/go/src/runtime/time.go:105 +0x1c0
main.main()
        /tmp/sandbox327672725/prog.go:81 +0x140

goroutine 5 [sleep]:
runtime.goparkunlock(...)
        /usr/local/go/src/runtime/proc.go:307
time.Sleep(0x1, 0x0)
        /usr/local/go/src/runtime/time.go:105 +0x1c0
main.producer(0x430150, 0x40a0e0)
        /tmp/sandbox327672725/prog.go:49 +0x60
created by main.main
        /tmp/sandbox327672725/prog.go:73 +0xe0

These routines are asleep, not blocked. They will awake from sleep (eventually) 
- so there cannot be a deadlock.

I am assuming this is a limitation of the Go playground back-end, but I can’t 
see it documented anywhere? Also, I’m not sure why this limitation would exist, 
since if all the routines are asleep or blocked, it is consuming no resources.

Ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/C7B46199-05EA-47C1-9594-200E2DD36F99%40ix.netcom.com.

Reply via email to