• Ian Lance Taylor's avatar
    io: Avoid race condition in pipe. · 7c1be45f
    Ian Lance Taylor authored
    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
    https://golang.org/cl/1682048
    7c1be45f
pipe.go 7.17 KB