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

runtime/race: race detector not detecting data race when mutex is used #18668

Closed
sarathsp06 opened this issue Jan 15, 2017 · 3 comments
Closed

Comments

@sarathsp06
Copy link

sarathsp06 commented Jan 15, 2017

What version of Go are you using (go version)?

go version go1.6.4 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/sarath/go"
GORACE=""
GOROOT="/home/sarath/goroot"
GOTOOLDIR="/home/sarath/goroot/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

What did you do?

I tried making a go program that has two routines runnig that writes to and read from a variable . The writes and read were protected by locks ,but since locks does not guarantee order of execution data race could happen . The race detector is not detecting that

Here is play link : https://play.golang.org/p/MGpRIkE2-L

What did you expect to see?

Data race error stack

What did you see instead?

No data race detected though it occured

@dgryski
Copy link
Contributor

dgryski commented Jan 15, 2017

/cc @dvyukov

@ALTree
Copy link
Member

ALTree commented Jan 15, 2017

There's no race on l (i.e. two or more threads accessing l concurrently, at least one on write); the fact that the order of execution of the goroutines is not guaranteed is not a data race.

@ALTree ALTree changed the title data race detector not detecting data race when mutex is used runtime/race: race detector not detecting data race when mutex is used Jan 15, 2017
@dvyukov
Copy link
Member

dvyukov commented Jan 15, 2017

This is not a data race, this is a high-level logical race. The race detector detects only data races.
Most logical races are intentional and it is not possible to distinguish between intentional and harmful unintentional races.
WAI

@dvyukov dvyukov closed this as completed Jan 15, 2017
@golang golang locked and limited conversation to collaborators Jan 15, 2018
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

5 participants