aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/type.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@golang.org>2016-05-25 13:19:11 -0400
committerDavid Crawshaw <crawshaw@golang.org>2016-05-26 14:43:27 +0000
commit56e5e0b69c92c9157c7db39112e27a4b5c026b48 (patch)
tree598e2e36ec88b4028f11d7cddf44d59f1dc13ed1 /src/runtime/type.go
parent6247ca2dbbdc13d6c80666119d182e119a2e7a5b (diff)
downloadgo-56e5e0b69c92c9157c7db39112e27a4b5c026b48.tar.gz
go-56e5e0b69c92c9157c7db39112e27a4b5c026b48.zip
runtime: tell race detector about reflectOffs.lock
Fixes #15832 Change-Id: I6f3f45e3c21edd0e093ecb1d8a067907863478f5 Reviewed-on: https://go-review.googlesource.com/23441 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Diffstat (limited to 'src/runtime/type.go')
-rw-r--r--src/runtime/type.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/runtime/type.go b/src/runtime/type.go
index 608c601abd..d7ec5573a9 100644
--- a/src/runtime/type.go
+++ b/src/runtime/type.go
@@ -169,6 +169,20 @@ var reflectOffs struct {
minv map[unsafe.Pointer]int32
}
+func reflectOffsLock() {
+ lock(&reflectOffs.lock)
+ if raceenabled {
+ raceacquire(unsafe.Pointer(&reflectOffs.lock))
+ }
+}
+
+func reflectOffsUnlock() {
+ if raceenabled {
+ racerelease(unsafe.Pointer(&reflectOffs.lock))
+ }
+ unlock(&reflectOffs.lock)
+}
+
func resolveNameOff(ptrInModule unsafe.Pointer, off nameOff) name {
if off == 0 {
return name{}
@@ -182,9 +196,9 @@ func resolveNameOff(ptrInModule unsafe.Pointer, off nameOff) name {
}
}
if md == nil {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
res, found := reflectOffs.m[int32(off)]
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
if !found {
println("runtime: nameOff", hex(off), "base", hex(base), "not in ranges:")
for next := &firstmoduledata; next != nil; next = next.next {
@@ -219,9 +233,9 @@ func (t *_type) typeOff(off typeOff) *_type {
}
}
if md == nil {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
res := reflectOffs.m[int32(off)]
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
if res == nil {
println("runtime: typeOff", hex(off), "base", hex(base), "not in ranges:")
for next := &firstmoduledata; next != nil; next = next.next {
@@ -252,9 +266,9 @@ func (t *_type) textOff(off textOff) unsafe.Pointer {
}
}
if md == nil {
- lock(&reflectOffs.lock)
+ reflectOffsLock()
res := reflectOffs.m[int32(off)]
- unlock(&reflectOffs.lock)
+ reflectOffsUnlock()
if res == nil {
println("runtime: textOff", hex(off), "base", hex(base), "not in ranges:")
for next := &firstmoduledata; next != nil; next = next.next {