Skip to content
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 Call.Error #2780

Closed
dvyukov opened this issue Jan 25, 2012 · 2 comments
Closed

net/rpc: data race on Call.Error #2780

dvyukov opened this issue Jan 25, 2012 · 2 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jan 25, 2012

pkg/net/rpc$ gotest under ThreadSanitizer
(http://code.google.com/p/data-race-test/wiki/ThreadSanitizerGo) outputs the following
error:

WARNING: Possible data race during write of size 1 at 0xf8400010d0: {{{
   T2 (L{}):
    #0  net/rpc..input ~/go/src/pkg/net/rpc/client.go:132
    #1  runtime.goexit ~/go/src/pkg/runtime/proc.c:266
  Concurrent read(s) happened at (OR AFTER) these points:
   T1 (L{}):
    #0  net/rpc..Call ~/go/src/pkg/net/rpc/client.go:286
    #1  net/rpc.TestClientWriteError ~/go/src/pkg/net/rpc/server_test.go:487
    #2  testing.tRunner ~/go/src/pkg/testing/testing.go:254
    #3  runtime.goexit ~/go/src/pkg/runtime/proc.c:266
  Location 0xf8400010d0 is 48 bytes inside a block starting at 0xf8400010a0 of size 80 allocated by T1 from heap:
    #0  net/rpc..Go ~/go/src/pkg/net/rpc/client.go:255
    #1  net/rpc..Call ~/go/src/pkg/net/rpc/client.go:285
    #2  net/rpc.TestClientWriteError ~/go/src/pkg/net/rpc/server_test.go:487
    #3  testing.tRunner ~/go/src/pkg/testing/testing.go:254
    #4  runtime.goexit ~/go/src/pkg/runtime/proc.c:266
}}}

The root issue is that both send() and input() may set Call.Error and send to Call.Done.
This leads to 2 serious problems. First, there is a read-write data race (that the tool
reports) on Call.Error, since it's an interface the race can lead to arbitrary memory
corruptions and crashes. Second, if a user reuses Done channel, it will be totally
confused by two notifications about completion of a single Call.
@rsc
Copy link
Contributor

rsc commented Jan 25, 2012

Comment 1:

Labels changed: added priority-go1, removed priority-triage.

@dvyukov
Copy link
Member Author

dvyukov commented Jan 27, 2012

Comment 2:

This issue was closed by revision 75397e6.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants