From 6d68fc8eeaf32375eda7208b62cedf6ee5d241d0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 15 Sep 2013 12:05:24 -0400 Subject: [PATCH] runtime: fix CPU profiling on Windows 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 215bcd8cd9..07515c54f9 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -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;