]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix CPU profiling on Windows
authorRuss Cox <rsc@golang.org>
Sun, 15 Sep 2013 16:05:24 +0000 (12:05 -0400)
committerRuss Cox <rsc@golang.org>
Sun, 15 Sep 2013 16:05:24 +0000 (12:05 -0400)
The test 'gp == m->curg' is not valid on Windows,
because the goroutine being profiled is not from the
current m.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13718043

src/pkg/runtime/proc.c

index 215bcd8cd90f25c54bff0e2469d97533c868419c..07515c54f94784672555a975b7b41a32c6ae0785 100644 (file)
@@ -2115,7 +2115,13 @@ runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp)
        // To recap, there are no constraints on the assembly being used for the
        // transition. We simply require that g and SP match and that the PC is not
        // in runtime.gogo.
-       if(gp == nil || gp != m->curg || (uintptr)sp < gp->stackguard - StackGuard || gp->stackbase < (uintptr)sp ||
+       //
+       // On Windows, one m is sending reports about all the g's, so gp == m->curg
+       // is not a useful comparison. The profilem function in os_windows.c has
+       // already checked that gp is a user g.
+       if(gp == nil ||
+          (!Windows && gp != m->curg) ||
+          (uintptr)sp < gp->stackguard - StackGuard || gp->stackbase < (uintptr)sp ||
           ((uint8*)runtime·gogo <= pc && pc < (uint8*)runtime·gogo + RuntimeGogoBytes))
                traceback = false;