-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
net/rpc: data race on non-net transport #5792
Labels
Milestone
Comments
The race happens NOT inside of kernel, it happens in our code. The race happens between read/write and close. Consider the following code: // thread 1 ... = write(pipe.fd, ....); // thread 2 close(pipe.fd); pipe.fd = -1; Thread 1 loads pipe.fd value into register, then thread 2 closes the fd, then some other thread 3 create a socket that happened to reuse the fd, then thread 1 sends your credit card number into random socket. In net.Conn we do very special things to prevent such things, i.e. read/write either uses still alive correct fd or do not issue read/write at all. All other things (files, pipes) are not like this, they are "single threaded", i.e. you can not call read/write and concurrently close it. |
Dmitriy, While we're on this subject, I would like to talk to you about (*netFD).Close. I could be wrong, but, I think, semantically windows and unix (*netFD).Close are different. One waits for all outstanding IO to finish, while the other does not. The questions here is: "What is guaranteed on (*netFD).Close return? Can it be assumed that all outstanding IO is completed and is flushed to OS or canceled? Can we be certain that OS socket is closed?". Perhaps it is not important, but I would like to run this concern by you. Alex |
The discussion of comment #9 moved to issue #6074. |
Here http://build.golang.org/log/06efb61af57fac64b4d04c3838eea04cb0eb37c6 is the race on windows builder. Alex |
Alex, that one is false positive, and it tracked in: https://golang.org/issue/7460 |
Rob and I have talked about this but we're still not sure how to do this correctly in net/rpc. It's not even clear to me that net/rpc is buggy. It might be that we just need to document what the expectations are for the interface. We should probably also fix os.File not to have this race. I filed issue #7970 for that. Labels changed: added release-go1.4, removed release-go1.3. |
We fixed #7970, so now there is no longer a race for pipes and socketpairs. I think everything is OK now. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
The text was updated successfully, but these errors were encountered: