-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/go: data race when running test with coverprofile #56006
Comments
This appears to be caused by a goroutine leaked by a test racing with the coverage instrumentation writing out the counters associated with that goroutine. The The leaked goroutine is started here: |
Thanks, I'll take a look. |
This is an interesting bug, since coverage counters are (in theory) supposed to be specially marked as such, and should be "invisible" to the race detector. The fact that you're seeing this problem is an indication that something is going wrong with this process.... more investigation needed. |
OK, the code added to the compiler intended to defeat the race detector instrumentation for coverage counters looks like it only applies to direct reads and writes, as opposed to those done via atomic read/write clls (where we don't have an option of turning things off). I'll rework the counter emit code to use atomics as well. |
Change https://go.dev/cl/438256 mentions this issue: |
Change https://go.dev/cl/438475 mentions this issue: |
Separate out the functions from cmd/internal/sys/support.go and migrate them to a new package internal/platform, so that functions such as "RaceDetectorSupported" can be called from tests in std as well as in cmd. This isn't a complete move of everything in cmd/internal/sys; there are still many functions left. The original version of this CL (patch set 1) called the new package "internal/sys", but for packages that needed both "internal/sys" and "cmd/internal/sys" the import of the former had to be done with a different name, which was confusing and also required a hack in cmd/dist. Updates #56006. Change-Id: I866d62e75adbf3a640a06e2c7386a6e9e2a18d91 Reviewed-on: https://go-review.googlesource.com/c/go/+/438475 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I run go test with -race and -coverprofile at the same time on github.com/shuLhan/share and the test are FAIL with data race.
There are many lines like that with the same pattern.
In the above snippet, the lib/dns/dns_test.go:63 point this code [1],
os.Exit(m.Run())
inside the TestMain. So it does not make sense if the data race is in my code.
A quick bisect point to this commit [2].
I run the test using GOEXPERIMENT=coverageredesign flag using Go tip commit 53773a5
Without GOEXPERIMENT flag,
With GOEXPERIMENT=coverageredesign flag,
[1] https://github.com/shuLhan/share/blob/61720a183756bdf5a8af45e7d75116ce7ef188e0/lib/dns/dns_test.go#L63
[2] https://go.googlesource.com/go/+/53773a5d0892be4489b4d5e91bbc8ae61000ada7%5E%21/
What did you expect to see?
All test running succesfully.
What did you see instead?
Some test are FAIL-ed due to data race but point to code that are not relevant (in this case the race is inside TestMain function).
The text was updated successfully, but these errors were encountered: