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

Issue 1682048: code review 1682048: Avoid race condition in pipe. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 9 months ago by iant
Modified:
14 years, 9 months ago
Reviewers:
CC:
rsc, rsc1, golang-dev
Visibility:
Public.

Description

io: Avoid race condition in pipe. One goroutine started up and was waiting in rw. Then another goroutine decided to close the pipe. The closing goroutine stalled calling p.io.Lock() in pipeHalf.close. (This happened in gccgo). If the closing goroutine had been able to set the ioclosed flag, it would have gone on to tell the runner that the pipe was closed, which would then send an EINVAL to the goroutine sleeping in rw. Unlocking p.io before sleeping in rw avoids the race.

Patch Set 1 #

Patch Set 2 : code review 1682048: Avoid race condition in pipe. #

Patch Set 3 : code review 1682048: io: Avoid race condition in pipe. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -1 line) Patch
M src/pkg/io/pipe.go View 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 4
iant
Hello golang-dev@googlegroups.com, I'd like you to review this change.
14 years, 9 months ago (2010-06-30 19:08:15 UTC) #1
iant
Hello rsc (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 9 months ago (2010-06-30 19:11:52 UTC) #2
rsc1
LGTM please change first line of description to begin with "io: "
14 years, 9 months ago (2010-06-30 19:15:02 UTC) #3
iant
14 years, 9 months ago (2010-06-30 20:14:51 UTC) #4
*** Submitted as http://code.google.com/p/go/source/detail?r=1c3b09eb63c1 ***

io: Avoid race condition in pipe.

One goroutine started up and was waiting in rw.  Then another
goroutine decided to close the pipe.  The closing goroutine
stalled calling p.io.Lock() in pipeHalf.close.  (This happened
in gccgo).  If the closing goroutine had been able to set the
ioclosed flag, it would have gone on to tell the runner that
the pipe was closed, which would then send an EINVAL to the
goroutine sleeping in rw.  Unlocking p.io before sleeping in
rw avoids the race.

R=rsc, rsc1
CC=golang-dev
http://codereview.appspot.com/1682048
Sign in to reply to this message.

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