Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(259)

Issue 5191044: code review 5191044: runtime: fix spurious deadlock reporting (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 5 months ago by dvyukov
Modified:
13 years, 5 months ago
Reviewers:
CC:
golang-dev, rsc
Visibility:
Public.

Description

runtime: fix spurious deadlock reporting Fixes issue 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

Patch Set 1 #

Patch Set 2 : diff -r a5126bbf1e47 https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 6bf2b47bba7b https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Patch Set 8 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Patch Set 9 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Patch Set 10 : diff -r ee8a3dd0f7c6 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+34 lines, -11 lines) Patch
M src/pkg/runtime/malloc.h View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/mgc0.c View 1 2 3 4 5 6 3 chunks +3 lines, -3 lines 0 comments Download
M src/pkg/runtime/proc.c View 1 2 3 4 5 6 7 4 chunks +12 lines, -7 lines 0 comments Download
A test/fixedbugs/bug370.go View 1 2 3 4 1 chunk +18 lines, -0 lines 0 comments Download

Messages

Total messages: 3
dvyukov
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 5 months ago (2011-10-06 15:05:31 UTC) #1
rsc
LGTM Thanks for tracking that down.
13 years, 5 months ago (2011-10-06 15:07:28 UTC) #2
dvyukov
13 years, 5 months ago (2011-10-06 15:10:56 UTC) #3
*** Submitted as http://code.google.com/p/go/source/detail?r=09557b41f0ab ***

runtime: fix spurious deadlock reporting
Fixes issue 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
http://codereview.appspot.com/5191044
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b