]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/race: update runtime to tip
authorDmitriy Vyukov <dvyukov@google.com>
Fri, 20 Jun 2014 23:36:21 +0000 (16:36 -0700)
committerDmitriy Vyukov <dvyukov@google.com>
Fri, 20 Jun 2014 23:36:21 +0000 (16:36 -0700)
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

src/pkg/runtime/proc.c
src/pkg/runtime/race.c
src/pkg/runtime/race/README
src/pkg/runtime/race/race_darwin_amd64.syso
src/pkg/runtime/race/race_linux_amd64.syso
src/pkg/runtime/race/race_windows_amd64.syso

index 914a02e0bf5492cd9907c5c1b235aea779f2a8e1..b81267210bcc0d56a84c21f48a319a8a87c267cc 100644 (file)
@@ -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);
index eb0be7fa6f905105ed0d5d350cad6c7193a89b5d..fd5aa3c9069eec959847069e466d034613812c33 100644 (file)
@@ -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);
 }
index 785640607cdbece7f0aba5ae7bef59c201c88a8f..6a4259141efc368dbb086f07d96d75e8140ca355 100644 (file)
@@ -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.
index 249a878ef42f60567446bc8299533a76ec8b3d41..9061ce0aa119f99a9694e8629c600ae6a68cdc2e 100644 (file)
Binary files a/src/pkg/runtime/race/race_darwin_amd64.syso and b/src/pkg/runtime/race/race_darwin_amd64.syso differ
index 8120484d48599e3762161eebc7080e526b45ea51..32b5c5259485f045960915eb0f15d114d757a267 100644 (file)
Binary files a/src/pkg/runtime/race/race_linux_amd64.syso and b/src/pkg/runtime/race/race_linux_amd64.syso differ
index 67db40f213c4903758717edec71c68363026ee16..3ea80a6657f5f83cd1e50ea78508f5481da13426 100644 (file)
Binary files a/src/pkg/runtime/race/race_windows_amd64.syso and b/src/pkg/runtime/race/race_windows_amd64.syso differ