summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2013-12-02 18:03:25 -0800
committerKeith Randall <khr@golang.org>2013-12-02 18:03:25 -0800
commit34497d7cf3d9a52f35d2c287dd00a9968bcd55f6 (patch)
tree6c3b84b3a8db9f4e94e456d4b0f44602e77a9509 /src
parente06bfe01ec95788edfb9e498b22ec78c469bbd7d (diff)
downloadgo-34497d7cf3d9a52f35d2c287dd00a9968bcd55f6.tar.gz
runtime: fix race detector when map keys/values are passed by pointer.
Now that the map implementation is reading the keys and values from arbitrary memory (instead of from stack slots), it needs to tell the race detector when it does so. Fixes issue 6875. R=golang-dev, dave CC=golang-dev https://codereview.appspot.com/36360043
Diffstat (limited to 'src')
-rw-r--r--src/pkg/runtime/hashmap.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c
index d67637b6d..5be159761 100644
--- a/src/pkg/runtime/hashmap.c
+++ b/src/pkg/runtime/hashmap.c
@@ -991,9 +991,10 @@ reflect·makemap(MapType *t, Hmap *ret)
void
runtime·mapaccess1(MapType *t, Hmap *h, byte *ak, byte *av)
{
- if(raceenabled && h != nil)
+ if(raceenabled && h != nil) {
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess1);
-
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess1);
+ }
if(h == nil || h->count == 0) {
av = t->elem->zero;
} else {
@@ -1021,8 +1022,10 @@ runtime·mapaccess1(MapType *t, Hmap *h, byte *ak, byte *av)
void
runtime·mapaccess2(MapType *t, Hmap *h, byte *ak, byte *av, bool pres)
{
- if(raceenabled && h != nil)
+ if(raceenabled && h != nil) {
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess2);
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess2);
+ }
if(h == nil || h->count == 0) {
av = t->elem->zero;
@@ -1097,8 +1100,11 @@ runtime·mapassign1(MapType *t, Hmap *h, byte *ak, byte *av)
if(h == nil)
runtime·panicstring("assignment to entry in nil map");
- if(raceenabled)
+ if(raceenabled) {
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapassign1);
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapassign1);
+ runtime·racereadpc(av, runtime·getcallerpc(&t), runtime·mapassign1);
+ }
hash_insert(t, h, ak, av);
@@ -1121,8 +1127,10 @@ runtime·mapdelete(MapType *t, Hmap *h, byte *ak)
if(h == nil)
return;
- if(raceenabled)
+ if(raceenabled) {
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapdelete);
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapdelete);
+ }
hash_remove(t, h, ak);