summaryrefslogtreecommitdiff
path: root/src/pkg/runtime
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-06-20 16:36:21 -0700
committerDmitriy Vyukov <dvyukov@google.com>2014-06-20 16:36:21 -0700
commit79e5fd6b531f117ca3b07fa16a9487fa5f4c07a8 (patch)
treee64d735ae2005ac876a500fffbd7903e7c3c991c /src/pkg/runtime
parent057813ccddddbc633394deb6390142f7ea4586f4 (diff)
downloadgo-79e5fd6b531f117ca3b07fa16a9487fa5f4c07a8.tar.gz
runtime/race: update runtime to tip
This requires minimal changes to the runtime hooks. In particular, synchronization events must be done only on valid addresses now, so I've added the additional checks to race.c. LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/101000046
Diffstat (limited to 'src/pkg/runtime')
-rw-r--r--src/pkg/runtime/proc.c8
-rw-r--r--src/pkg/runtime/race.c19
-rw-r--r--src/pkg/runtime/race/README2
-rw-r--r--src/pkg/runtime/race/race_darwin_amd64.sysobin222964 -> 249744 bytes
-rw-r--r--src/pkg/runtime/race/race_linux_amd64.sysobin243208 -> 267968 bytes
-rw-r--r--src/pkg/runtime/race/race_windows_amd64.sysobin210859 -> 247609 bytes
6 files changed, 22 insertions, 7 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c
index 914a02e0b..b81267210 100644
--- a/src/pkg/runtime/proc.c
+++ b/src/pkg/runtime/proc.c
@@ -143,6 +143,11 @@ runtime·schedinit(void)
byte *p;
Eface i;
+ // raceinit must be the first call to race detector.
+ // In particular, it must be done before mallocinit below calls racemapshadow.
+ if(raceenabled)
+ g->racectx = runtime·raceinit();
+
runtime·sched.maxmcount = 10000;
runtime·precisestack = true; // haveexperiment("precisestack");
@@ -181,9 +186,6 @@ runtime·schedinit(void)
runtime·copystack = false;
mstats.enablegc = 1;
-
- if(raceenabled)
- g->racectx = runtime·raceinit();
}
extern void main·init(void);
diff --git a/src/pkg/runtime/race.c b/src/pkg/runtime/race.c
index eb0be7fa6..fd5aa3c90 100644
--- a/src/pkg/runtime/race.c
+++ b/src/pkg/runtime/race.c
@@ -63,6 +63,17 @@ void runtime·racesymbolizethunk(void*);
// with up to 4 uintptr arguments.
void runtime·racecall(void(*f)(void), ...);
+// checks if the address has shadow (i.e. heap or data/bss)
+static bool
+isvalidaddr(uintptr addr)
+{
+ if(addr >= runtime·racearenastart && addr < runtime·racearenaend)
+ return true;
+ if(addr >= (uintptr)noptrdata && addr < (uintptr)enoptrbss)
+ return true;
+ return false;
+}
+
uintptr
runtime·raceinit(void)
{
@@ -169,7 +180,7 @@ runtime·raceacquire(void *addr)
void
runtime·raceacquireg(G *gp, void *addr)
{
- if(g->raceignore)
+ if(g->raceignore || !isvalidaddr((uintptr)addr))
return;
runtime·racecall(__tsan_acquire, gp->racectx, addr);
}
@@ -177,13 +188,15 @@ runtime·raceacquireg(G *gp, void *addr)
void
runtime·racerelease(void *addr)
{
+ if(g->raceignore || !isvalidaddr((uintptr)addr))
+ return;
runtime·racereleaseg(g, addr);
}
void
runtime·racereleaseg(G *gp, void *addr)
{
- if(g->raceignore)
+ if(g->raceignore || !isvalidaddr((uintptr)addr))
return;
runtime·racecall(__tsan_release, gp->racectx, addr);
}
@@ -197,7 +210,7 @@ runtime·racereleasemerge(void *addr)
void
runtime·racereleasemergeg(G *gp, void *addr)
{
- if(g->raceignore)
+ if(g->raceignore || !isvalidaddr((uintptr)addr))
return;
runtime·racecall(__tsan_release_merge, gp->racectx, addr);
}
diff --git a/src/pkg/runtime/race/README b/src/pkg/runtime/race/README
index 785640607..6a4259141 100644
--- a/src/pkg/runtime/race/README
+++ b/src/pkg/runtime/race/README
@@ -9,4 +9,4 @@ $ ./buildgo.sh
Tested with gcc 4.6.1 and 4.7.0. On Windows it's built with 64-bit MinGW.
-Current runtime is built on rev 203116.
+Current runtime is built on rev 210365.
diff --git a/src/pkg/runtime/race/race_darwin_amd64.syso b/src/pkg/runtime/race/race_darwin_amd64.syso
index 249a878ef..9061ce0aa 100644
--- a/src/pkg/runtime/race/race_darwin_amd64.syso
+++ b/src/pkg/runtime/race/race_darwin_amd64.syso
Binary files differ
diff --git a/src/pkg/runtime/race/race_linux_amd64.syso b/src/pkg/runtime/race/race_linux_amd64.syso
index 8120484d4..32b5c5259 100644
--- a/src/pkg/runtime/race/race_linux_amd64.syso
+++ b/src/pkg/runtime/race/race_linux_amd64.syso
Binary files differ
diff --git a/src/pkg/runtime/race/race_windows_amd64.syso b/src/pkg/runtime/race/race_windows_amd64.syso
index 67db40f21..3ea80a665 100644
--- a/src/pkg/runtime/race/race_windows_amd64.syso
+++ b/src/pkg/runtime/race/race_windows_amd64.syso
Binary files differ