aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proflabel.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-04-28 12:45:46 -0400
committerRuss Cox <rsc@golang.org>2017-04-28 17:37:46 +0000
commitc82efb1fa370ea83a7e9ff89d85598bb0fdc3fb5 (patch)
treedbc2d7bbc40f5b368e2344797308fd6808b2d783 /src/runtime/proflabel.go
parent50f67add81eb9fa032f2e87c639fc42f0cc9de72 (diff)
downloadgo-c82efb1fa370ea83a7e9ff89d85598bb0fdc3fb5.tar.gz
go-c82efb1fa370ea83a7e9ff89d85598bb0fdc3fb5.zip
runtime: fix profile handling of labels for race detector
If g1 sets its labels and then they are copied into a profile buffer and then g2 reads the profile buffer and inspects the labels, the race detector must understand that g1's recording of the labels happens before g2's use of the labels. Make that so. Fixes race test failure in CL 39613. Change-Id: Id7cda1c2aac6f8eef49213b5ca414f7154b4acfa Reviewed-on: https://go-review.googlesource.com/42111 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/runtime/proflabel.go')
-rw-r--r--src/runtime/proflabel.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/proflabel.go b/src/runtime/proflabel.go
index 9742afafd7..1b41a8a16e 100644
--- a/src/runtime/proflabel.go
+++ b/src/runtime/proflabel.go
@@ -6,8 +6,16 @@ package runtime
import "unsafe"
+var labelSync uintptr
+
//go:linkname runtime_setProfLabel runtime/pprof.runtime_setProfLabel
func runtime_setProfLabel(labels unsafe.Pointer) {
+ // Introduce race edge for read-back via profile.
+ // This would more properly use &getg().labels as the sync address,
+ // but we do the read in a signal handler and can't call the race runtime then.
+ if raceenabled {
+ racerelease(unsafe.Pointer(&labelSync))
+ }
getg().labels = labels
}