]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix race detector running Go code on g0 of non-main thread
authorRuss Cox <rsc@golang.org>
Tue, 2 Sep 2014 01:55:57 +0000 (21:55 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 2 Sep 2014 01:55:57 +0000 (21:55 -0400)
It looks like this has just always been broken:
the race detector handles running Go code on g0 of the main thread
and on g0 of any extra threads created by non-Go code, but it does
not handle running Go code on g0 of non-main threads created by Go.
Handle that.

Should fix the race build failures on the dashboard.

We're running into this now because we are running more
and more Go code on g0.

TBR=dvyukov
CC=golang-codereviews
https://golang.org/cl/137910043

src/pkg/runtime/proc.c

index 9143fcf596eab6e3dc010e6c932c36b083b0669e..1a82c8e541316366406c7f08a0164ea7caf2a94f 100644 (file)
@@ -1077,6 +1077,8 @@ newm(void(*fn)(void), P *p)
        mp = runtime·allocm(p);
        mp->nextp = p;
        mp->mstartfn = fn;
+       if(raceenabled)
+               mp->g0->racectx = runtime·racegostart(newm);
 
        if(runtime·iscgo) {
                CgoThreadStart ts;