From f38ff9e5ea24d1ea27928cfdc35c4679abe4673f Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Mon, 5 Aug 2013 23:33:50 +0400 Subject: [PATCH] undo CL 12250043 / e911f94c4902 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Break all 386 builders. ««« original CL description runtime: use gcpc/gcsp during traceback of goroutines in syscalls gcpc/gcsp are used by GC in similar situation. gcpc/gcsp are also more stable than gp->sched, because gp->sched is mutated by entersyscall/exitsyscall in morestack and mcall. So it has higher chances of being inconsistent. Also, rename gcpc/gcsp to syscallpc/syscallsp. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/12250043 »»» R=rsc CC=golang-dev https://golang.org/cl/12424045 --- src/pkg/runtime/mgc0.c | 10 ++++----- src/pkg/runtime/proc.c | 39 +++++++++++++++++---------------- src/pkg/runtime/runtime.h | 8 +++---- src/pkg/runtime/traceback_arm.c | 4 ++-- src/pkg/runtime/traceback_x86.c | 4 ++-- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/pkg/runtime/mgc0.c b/src/pkg/runtime/mgc0.c index be0f81879e..f5b8d3e3cc 100644 --- a/src/pkg/runtime/mgc0.c +++ b/src/pkg/runtime/mgc0.c @@ -1457,17 +1457,17 @@ addstackroots(G *gp) runtime·throw("can't scan our own stack"); if((mp = gp->m) != nil && mp->helpgc) runtime·throw("can't scan gchelper stack"); - if(gp->syscallstack != (uintptr)nil) { + if(gp->gcstack != (uintptr)nil) { // Scanning another goroutine that is about to enter or might // have just exited a system call. It may be executing code such // as schedlock and may have needed to start a new stack segment. // Use the stack segment and stack pointer at the time of // the system call instead, since that won't change underfoot. - sp = gp->syscallsp; - pc = gp->syscallpc; + sp = gp->gcsp; + pc = gp->gcpc; lr = 0; - stk = (Stktop*)gp->syscallstack; - guard = gp->syscallguard; + stk = (Stktop*)gp->gcstack; + guard = gp->gcguard; } else { // Scanning another goroutine's stack. // The goroutine is usually asleep (the world is stopped). diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 725a49668b..cff30c8ffa 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -1358,6 +1358,8 @@ goexit0(G *gp) static void save(void *pc, uintptr sp) { + g->gcpc = (uintptr)pc; + g->gcsp = sp; g->sched.pc = (uintptr)pc; g->sched.sp = sp; g->sched.lr = 0; @@ -1385,16 +1387,15 @@ void if(m->profilehz > 0) runtime·setprof(false); - // Leave SP around for GC and traceback. + // Leave SP around for gc and traceback. save(runtime·getcallerpc(&dummy), runtime·getcallersp(&dummy)); - g->syscallsp = g->sched.sp; - g->syscallpc = g->sched.pc; - g->syscallstack = g->stackbase; - g->syscallguard = g->stackguard; + + g->gcstack = g->stackbase; + g->gcguard = g->stackguard; g->status = Gsyscall; - if(g->syscallsp < g->syscallguard-StackGuard || g->syscallstack < g->syscallsp) { + if(g->gcsp < g->gcguard-StackGuard || g->gcstack < g->gcsp) { // runtime·printf("entersyscall inconsistent %p [%p,%p]\n", - // g->syscallsp, g->syscallguard-StackGuard, g->syscallstack); + // g->gcsp, g->gcguard-StackGuard, g->gcstack); runtime·throw("entersyscall"); } @@ -1441,16 +1442,16 @@ void if(m->profilehz > 0) runtime·setprof(false); - // Leave SP around for GC and traceback. + // Leave SP around for gc and traceback. save(runtime·getcallerpc(&dummy), runtime·getcallersp(&dummy)); - g->syscallsp = g->sched.sp; - g->syscallpc = g->sched.pc; - g->syscallstack = g->stackbase; - g->syscallguard = g->stackguard; + g->gcsp = g->sched.sp; + g->gcpc = g->sched.pc; + g->gcstack = g->stackbase; + g->gcguard = g->stackguard; g->status = Gsyscall; - if(g->syscallsp < g->syscallguard-StackGuard || g->syscallstack < g->syscallsp) { - // runtime·printf("entersyscall inconsistent %p [%p,%p]\n", - // g->syscallsp, g->syscallguard-StackGuard, g->syscallstack); + if(g->gcsp < g->gcguard-StackGuard || g->gcstack < g->gcsp) { + // runtime·printf("entersyscallblock inconsistent %p [%p,%p]\n", + // g->gcsp, g->gcguard-StackGuard, g->gcstack); runtime·throw("entersyscallblock"); } @@ -1489,8 +1490,8 @@ runtime·exitsyscall(void) g->status = Grunning; // Garbage collector isn't running (since we are), // so okay to clear gcstack and gcsp. - g->syscallstack = (uintptr)nil; - g->syscallsp = (uintptr)nil; + g->gcstack = (uintptr)nil; + g->gcsp = (uintptr)nil; m->locks--; if(g->preempt) { // restore the preemption request in case we've cleared it in newstack @@ -1513,8 +1514,8 @@ runtime·exitsyscall(void) // Must wait until now because until gosched returns // we don't know for sure that the garbage collector // is not running. - g->syscallstack = (uintptr)nil; - g->syscallsp = (uintptr)nil; + g->gcstack = (uintptr)nil; + g->gcsp = (uintptr)nil; } #pragma textflag 7 diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index 951376a52f..cc38953135 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -253,10 +253,10 @@ struct G Defer* defer; Panic* panic; Gobuf sched; - uintptr syscallstack; // if status==Gsyscall, syscallstack = stackbase to use during gc - uintptr syscallguard; // if status==Gsyscall, syscallguard = stackguard to use during gc - uintptr syscallsp; // if status==Gsyscall, syscallsp = sched.sp to use during gc - uintptr syscallpc; // if status==Gsyscall, syscallpc = sched.pc to use during gc + uintptr gcstack; // if status==Gsyscall, gcstack = stackbase to use during gc + uintptr gcsp; // if status==Gsyscall, gcsp = sched.sp to use during gc + uintptr gcpc; // if status==Gsyscall, gcpc = sched.pc to use during gc + uintptr gcguard; // if status==Gsyscall, gcguard = stackguard to use during gc uintptr stackguard; // same as stackguard0, but not set to StackPreempt uintptr stack0; G* alllink; // on allg diff --git a/src/pkg/runtime/traceback_arm.c b/src/pkg/runtime/traceback_arm.c index 74725ba4ca..78ec5482db 100644 --- a/src/pkg/runtime/traceback_arm.c +++ b/src/pkg/runtime/traceback_arm.c @@ -221,8 +221,8 @@ runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp) { if(gp->status == Gsyscall) { // Override signal registers if blocked in system call. - pc = gp->syscallpc; - sp = gp->syscallsp; + pc = gp->sched.pc; + sp = gp->sched.sp; lr = 0; } diff --git a/src/pkg/runtime/traceback_x86.c b/src/pkg/runtime/traceback_x86.c index 78f8bd5aad..7f89b78fde 100644 --- a/src/pkg/runtime/traceback_x86.c +++ b/src/pkg/runtime/traceback_x86.c @@ -229,8 +229,8 @@ runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp) if(gp->status == Gsyscall) { // Override signal registers if blocked in system call. - pc = gp->syscallpc; - sp = gp->syscallsp; + pc = gp->sched.pc; + sp = gp->sched.sp; } // Print traceback. By default, omits runtime frames. -- 2.48.1