microsoft/go-winio

Race condition in `makeConnectedServerPipe` causes `win32PipeListener.Close()` deadlock

Opened this issue · 0 comments

On line 273 in pipe.go, makeConnectedServerPipe signals to the connectPipe goroutine that the listener has been closed by closing the underlying pipe it is trying to connect. However, if the connectPipe call succeeds before the call to p.Close(), then err may also be one of cERROR_PIPE_CONNECTED or cERROR_NO_DATA. This causes makeConnectedServerPipe to effectively swallow the control signal sent over l.closeCh, preventing listenerRoutine from accepting it, causing win32PipeListener.Close() to deadlock without ever closing the listener.

I have been able to reproduce this behavior while developing #84, but only by running go test in a loop until the deadlock occurs.