]> Cypherpunks repositories - gostls13.git/commit
runtime: fix spurious deadlock reporting
authorDmitriy Vyukov <dvyukov@google.com>
Thu, 6 Oct 2011 15:10:14 +0000 (18:10 +0300)
committerDmitriy Vyukov <dvyukov@google.com>
Thu, 6 Oct 2011 15:10:14 +0000 (18:10 +0300)
commit56959158331072ed17801aa539a0d6f28064b511
tree1420df3557880dd9b7a0bbd343bf3aaedb231b78
parent504963e6a466bd0c13c6f36f1ca129602151e598
runtime: fix spurious deadlock reporting
Fixes #2337.
Unfortunate sequence of events is:
1. maxcpu=2, mcpu=1, grunning=1
2. starttheworld creates an extra M:
   maxcpu=2, mcpu=2, grunning=1
4. the goroutine calls runtime.GOMAXPROCS(1)
   maxcpu=1, mcpu=2, grunning=1
5. since it sees mcpu>maxcpu, it calls gosched()
6. schedule() deschedules the goroutine:
   maxcpu=1, mcpu=1, grunning=0
7. schedule() call getnextandunlock() which
   fails to pick up the goroutine again,
   because canaddcpu() fails, because mcpu==maxcpu
8. then it sees that grunning==0,
   reports deadlock and terminates

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5191044
src/pkg/runtime/malloc.h
src/pkg/runtime/mgc0.c
src/pkg/runtime/proc.c
test/fixedbugs/bug370.go [new file with mode: 0644]