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

Issue 6545051: code review 6545051: pkg/syscall, pkg/os: Fix a fork-exec/wait race in Plan 9. (Closed)

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

Description

syscall, os: Fix a fork-exec/wait race in Plan 9. On Plan 9, only the parent of a given process can enter its wait queue. When a Go program tries to fork-exec a child process and subsequently waits for it to finish, the goroutines doing these two tasks do not necessarily tie themselves to the same (or any single) OS thread. In the case that the fork and the wait system calls happen on different OS threads (say, due to a goroutine being rescheduled somewhere along the way), the wait() will either return an error or end up waiting for a completely different child than was intended. This change forces the fork and wait syscalls to happen in the same goroutine and ties that goroutine to its OS thread until the child exits. The PID of the child is recorded upon fork and exit, and de-queued once the child's wait message has been read. The Wait API, then, is translated into a synthetic implementation that simply waits for the requested PID to show up in the queue and then reads the associated stats.

Patch Set 1 #

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

Patch Set 3 : diff -r 90c9121e26c3 https://go.googlecode.com/hg/ #

Total comments: 26

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

Total comments: 12

Patch Set 5 : diff -r 7ea3674ce4b5 https://code.google.com/p/go #

Total comments: 11

Patch Set 6 : diff -r 43203aa69a8a https://code.google.com/p/go #

Total comments: 19

Patch Set 7 : diff -r c53ac9baac67 https://code.google.com/p/go #

Total comments: 10

Patch Set 8 : diff -r 6519eef2c815 https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+97 lines, -13 lines) Patch
M src/pkg/os/exec_plan9.go View 1 2 3 4 5 1 chunk +4 lines, -12 lines 0 comments Download
M src/pkg/syscall/exec_plan9.go View 1 2 3 4 5 6 7 3 chunks +93 lines, -1 line 0 comments Download

Messages

Total messages: 27
akumar
Hello rsc@golang.org, rminnich@gmail.com, npe@plan9.bell-labs.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 9 months ago (2012-09-21 10:27:11 UTC) #1
aam
nice! tests now actually pass, wow! go test -short std broke at database/sql. it appears ...
13 years, 9 months ago (2012-09-21 16:12:12 UTC) #2
rminnich
This gets us over a major hurdle. LGTM
13 years, 9 months ago (2012-09-21 19:46:26 UTC) #3
aam
what I encountered after a day of running go test with this CL in: - ...
13 years, 9 months ago (2012-09-22 01:01:34 UTC) #4
akumar
Yes, there are definitely more issues in the go runtime for Plan 9 to be ...
13 years, 9 months ago (2012-09-22 18:26:02 UTC) #5
rsc
http://codereview.appspot.com/6545051/diff/4001/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): http://codereview.appspot.com/6545051/diff/4001/src/pkg/syscall/exec_plan9.go#newcode519 src/pkg/syscall/exec_plan9.go:519: // Plan 9, only the parent thread can ever ...
13 years, 9 months ago (2012-09-24 15:46:11 UTC) #6
akumar
PTAL. https://codereview.appspot.com/6545051/diff/4001/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/4001/src/pkg/syscall/exec_plan9.go#newcode519 src/pkg/syscall/exec_plan9.go:519: // Plan 9, only the parent thread can ...
13 years, 9 months ago (2012-09-30 21:22:13 UTC) #7
akumar
ping On 2012/09/30 21:22:13, akumar wrote: > PTAL. > > https://codereview.appspot.com/6545051/diff/4001/src/pkg/syscall/exec_plan9.go > File src/pkg/syscall/exec_plan9.go (right): ...
13 years, 8 months ago (2012-10-24 01:22:09 UTC) #8
rsc
Getting close. https://codereview.appspot.com/6545051/diff/10010/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/10010/src/pkg/syscall/exec_plan9.go#newcode516 src/pkg/syscall/exec_plan9.go:516: cond *sync.Cond cond sync.Cond https://codereview.appspot.com/6545051/diff/10010/src/pkg/syscall/exec_plan9.go#newcode522 src/pkg/syscall/exec_plan9.go:522: procs.cond ...
13 years, 7 months ago (2012-11-01 16:40:32 UTC) #9
ality
What's the status of this CL? Thanks, Anthony
13 years, 7 months ago (2012-11-27 00:46:15 UTC) #10
akumar
Hey, sorry, I went out of country and then got caught up in other projects. ...
13 years, 6 months ago (2012-12-06 06:24:47 UTC) #11
rsc
I think we're waiting for Akshat to address my last round of comments.
13 years, 6 months ago (2012-12-06 06:30:47 UTC) #12
akumar
PTAL. https://codereview.appspot.com/6545051/diff/10010/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/10010/src/pkg/syscall/exec_plan9.go#newcode516 src/pkg/syscall/exec_plan9.go:516: cond *sync.Cond On 2012/11/01 16:40:32, rsc wrote: > ...
13 years, 6 months ago (2012-12-17 18:47:30 UTC) #13
akumar
ping? On 17 December 2012 10:47, <seed@mail.nanosouffle.net> wrote: > PTAL. > > > https://codereview.appspot.com/6545051/diff/10010/src/pkg/syscall/exec_plan9.go > ...
13 years, 6 months ago (2012-12-20 21:33:27 UTC) #14
akumar
ping once more On 20 December 2012 13:33, Akshat Kumar <seed@mail.nanosouffle.net> wrote: > ping? > ...
13 years, 5 months ago (2013-01-04 05:41:09 UTC) #15
rsc
https://codereview.appspot.com/6545051/diff/28001/src/pkg/os/exec_plan9.go File src/pkg/os/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/28001/src/pkg/os/exec_plan9.go#newcode79 src/pkg/os/exec_plan9.go:79: for true { s/for true/for/ https://codereview.appspot.com/6545051/diff/28001/src/pkg/os/exec_plan9.go#newcode79 src/pkg/os/exec_plan9.go:79: for true ...
13 years, 5 months ago (2013-01-07 05:10:00 UTC) #16
akumar
Thanks Russ, for these wonderful improvements. I hope I've implemented them properly. https://codereview.appspot.com/6545051/diff/28001/src/pkg/os/exec_plan9.go File src/pkg/os/exec_plan9.go ...
13 years, 5 months ago (2013-01-08 04:59:47 UTC) #17
akumar
On a second thought, I think this is not quite right: in buying the ability ...
13 years, 5 months ago (2013-01-08 10:12:34 UTC) #18
akumar
Ah, looking into runtime.LockOSThread() again, I think your method indeed works because only the goroutine ...
13 years, 5 months ago (2013-01-08 22:29:39 UTC) #19
ality
This is pretty close. I have just a few nitpicks. Thanks for fixing this. https://codereview.appspot.com/6545051/diff/37001/src/pkg/syscall/exec_plan9.go ...
13 years, 5 months ago (2013-01-10 00:46:32 UTC) #20
akumar
PTAL. https://codereview.appspot.com/6545051/diff/37001/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/37001/src/pkg/syscall/exec_plan9.go#newcode514 src/pkg/syscall/exec_plan9.go:514: func makeProcs() { On 2013/01/10 00:46:32, ality wrote: ...
13 years, 5 months ago (2013-01-12 23:37:05 UTC) #21
rsc
https://codereview.appspot.com/6545051/diff/44001/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/44001/src/pkg/syscall/exec_plan9.go#newcode546 src/pkg/syscall/exec_plan9.go:546: procs.once.Do(makeProcs) This is unnecessary, since procs is locked just ...
13 years, 5 months ago (2013-01-18 20:28:15 UTC) #22
akumar
PTAL. https://codereview.appspot.com/6545051/diff/44001/src/pkg/syscall/exec_plan9.go File src/pkg/syscall/exec_plan9.go (right): https://codereview.appspot.com/6545051/diff/44001/src/pkg/syscall/exec_plan9.go#newcode546 src/pkg/syscall/exec_plan9.go:546: procs.once.Do(makeProcs) On 2013/01/18 20:28:15, rsc wrote: > This ...
13 years, 5 months ago (2013-01-18 21:38:37 UTC) #23
rsc
LGTM
13 years, 5 months ago (2013-01-18 21:41:40 UTC) #24
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=12eff5fd6f09 *** syscall, os: fix a fork-exec/wait race in Plan 9. On ...
13 years, 5 months ago (2013-01-18 21:43:29 UTC) #25
akumar
Russ, looking at package syscall again, I think my point below still stands: we are ...
13 years, 5 months ago (2013-01-18 21:43:41 UTC) #26
rsc
13 years, 5 months ago (2013-01-18 21:49:01 UTC) #27
Sure, send a CL.
Sign in to reply to this message.

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