-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime/race: unexpected race when Conn.Close used for synchronization #22132
Comments
If the Dial and Read were to return errors for whatever reason, you would have a read before the write. |
That's not true for Dial - we exit if Dial returns an error, but I added a couple more error checks to make the code clearer. I fixed the link above to point to the new code. |
I think you may be asking too much of the race detector. There is no obvious reason that the two different network connections are related. I mean, sure, they are, but only if you know that the CC @dvyukov |
@ianlancetaylor Does that apply to any causal connection through a network connection (for example using an httptest.Server and relying on being able to read variables after an HTTP request has replied) ? |
To the best of my knowledge, yes. |
Interesting; it's not something I'd previously considered. I suspect we have hundreds of potentially race-flagged tests with this issue. |
I still see two different issues with the way it is written.
Unless my understanding of how things could work is inaccurate. |
Since |
Ultimately any system call can synchronize with any other system call (e.g. create a file, another process notices that the dir becomes non-empty and send us a signal, so now creation of the file is somehow synchronized with arrival of the signal). But synchronizing everything with everything has a substantial negative effect in that it masks real data races. In C++ we do more elaborate logic and e.g. actually track that connection between the pair of fd's returned by pipe and then how that propagates via dup's: To summarize: I don't see anything simple that we could do for Go to solve the problem. If we are talking about tests, I would suggest to add a separate chan that notifies about completion of handling of request/connection. |
go version devel +a714470 Wed Sep 27 16:29:18 2017 +0000 linux/amd64
The following program reports a race even though the read of x
cannot happen in parallel with the assignment to x because
we wait for the connection to be closed before reading it.
https://play.golang.org/p/ufvoScCbSm
The text was updated successfully, but these errors were encountered: