Skip to content

runtime/race: false positive in reflect during net/rpc test #7460

@rsc

Description

@rsc
See http://build.golang.org/log/b2cd252bfeae7df4a89e41af488bffd8104f3228 for an example.

It says that the race is on the writes to e.word, but e.word is writing to the local
variable i, which is on the stack. 'go build -gcflags -m reflect' confirms this:

./value.go:128: packEface &i does not escape

Here is the race report:

WARNING: DATA RACE
Write by goroutine 16:
  reflect.packEface()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/reflect/value.go:153 +0x27d
  reflect.valueInterface()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/reflect/value.go:1081 +0x28c
  reflect.Value.Interface()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/reflect/value.go:1051 +0x7b
  net/rpc.(*service).call()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/net/rpc/server.go:389 +0x3dc

Previous write by goroutine 62:
  reflect.packEface()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/reflect/value.go:153 +0x27d
  reflect.valueInterface()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/reflect/value.go:1081 +0x28c
  reflect.Value.Interface()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/reflect/value.go:1051 +0x7b
  net/rpc.(*service).call()
      /Users/builder/workspace/darwin-amd64-race-cheney-2b66d388d1af/go/src/pkg/net/rpc/server.go:389 +0x3dc

This seems like a bug in the race detector. Why is it reporting a race on a stack
variable?
Is it that the two goroutines ran one after the other and wrote to the same location?
That's a little surprising to show up as a false positive.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions