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: Data race in append() missed by the race detector #22762
Comments
Interestingly for me the example outputs race warnings in a similar environment (100 runs out of 100):
This is an official build — go version go1.9.2 darwin/amd64 from
|
I also see a data race warning. Please show us the exact commands that you are executing and exactly what you see. Thanks. |
I ran this with go run -race |
Odd. I see the race with both Can you show us the complete output of |
go run tx.go ‹system› goroutine 4 [running]: goroutine 8 [running]: go run -race tx.go ‹system›WARNING: DATA RACE Previous write at 0x00c420016080 by goroutine 5: Goroutine 6 (running) created at: Goroutine 5 (running) created at:
|
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN="/Users/escapist/gocode/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/escapist/gocode/"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_l/pbv9psw11872p3zrn8dptkq40000gn/T/go-build881315384=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
I run the following sample code with -race option:
code is also available at https://play.golang.org/p/L9SMvPzfcu
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
Append to a fixed slice with capacity larger than size is not thread-safe because every goroutine is trying to write data to same memory location in the underlying array.
I expect the data race to be detected by the race detector.
What did you see instead?
The race detector missed the data race and every goroutine could see a slice with an unexpected value.
The text was updated successfully, but these errors were encountered: