Commit 0d723646 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

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://golang.org/cl/101000046
parent 382c461a
......@@ -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);
......
......@@ -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);
}
......
......@@ -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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment