]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/race: more precise handling of finalizers
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 14 Nov 2012 12:58:10 +0000 (16:58 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 14 Nov 2012 12:58:10 +0000 (16:58 +0400)
Currently race detector runtime just disables race detection in the finalizer goroutine.
It has false positives when a finalizer writes to shared memory -- the race with finalizer is reported in a normal goroutine that accesses the same memory.
After this change I am going to synchronize the finalizer goroutine with the rest of the world in racefingo(). This is closer to what happens in reality and so
does not have false positives.
And also add README file with instructions how to build the runtime.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6810095

src/pkg/runtime/mgc0.c
src/pkg/runtime/race/README [new file with mode: 0644]
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 ab68619d0093eaea98253e68f45d2da4950496fa..5ad09d53b1e69c938d3f3607bff69471bb0dc68a 100644 (file)
@@ -1137,9 +1137,6 @@ runfinq(void)
        byte *frame;
        uint32 framesz, framecap, i;
 
-       if(raceenabled)
-               runtime·racefingo();
-
        frame = nil;
        framecap = 0;
        for(;;) {
@@ -1156,6 +1153,8 @@ runfinq(void)
                        runtime·park(nil, nil, "finalizer wait");
                        continue;
                }
+               if(raceenabled)
+                       runtime·racefingo();
                for(; fb; fb=next) {
                        next = fb->next;
                        for(i=0; i<fb->cnt; i++) {
diff --git a/src/pkg/runtime/race/README b/src/pkg/runtime/race/README
new file mode 100644 (file)
index 0000000..8bedb09
--- /dev/null
@@ -0,0 +1,11 @@
+runtime/race package contains the data race detector runtime library.
+It is based on ThreadSanitizer race detector, that is currently a part of
+the LLVM project.
+
+To update the .syso files you need to:
+$ svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk
+$ cd compiler-rt/lib/tsan/go
+$ ./buildgo.sh
+
+Tested with gcc 4.6.1 and 4.7.0.  On Windows it's built with 64-bit MinGW.
+
index b323a7129744adbc4bfc918aa12f63c37cc9c051..0caa119303c8708ef50aaae741e1d8123756d197 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 ccc42e57ca615447cdce1d7822cc79d61ca286f9..d58aea78a4526f8e10f511331bee653fc39ca830 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 9aecde4458b71866d56c6bb3de9d1609e9ca57ed..df693d9b7b4147b6fbed4b870719fc88790fe732 100644 (file)
Binary files a/src/pkg/runtime/race/race_windows_amd64.syso and b/src/pkg/runtime/race/race_windows_amd64.syso differ