]> Cypherpunks repositories - gostls13.git/commit
runtime/coverage: use atomic access for counter reads
authorThan McIntosh <thanm@google.com>
Mon, 3 Oct 2022 22:40:59 +0000 (18:40 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 4 Oct 2022 18:49:20 +0000 (18:49 +0000)
commitcddf792428be5f750a0be397c7c534870c682e52
tree8ff1b926e86141457b4c6e6baee7828eb3338346
parent8bd803fd4ea3a549a9124f5a4e18af9596ef35df
runtime/coverage: use atomic access for counter reads

Read counters using atomic ops so as to avoid problems with the race
detector if a goroutine happens to still be executing at the end of a
test run when we're writing out counter data. In theory we could guard
the atomic use on the counter mode, but it's better just to do it in
all cases, leaves us with a simpler implementation.

Fixes #56006.

Change-Id: I81c2234b5a1c3b00cff6c77daf2c2315451b7f6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/438256
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
src/runtime/coverage/apis.go
src/runtime/coverage/emit.go
src/runtime/coverage/emitdata_test.go
src/runtime/coverage/testdata/issue56006/repro.go [new file with mode: 0644]
src/runtime/coverage/testdata/issue56006/repro_test.go [new file with mode: 0644]