From 4b78c9575d3b1190c63b25761dfb86f4d1715c2e Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 28 Apr 2015 14:53:19 -0700 Subject: [PATCH] runtime: print stack of G during a signal Sequence of operations: - Go code does a systemstack call - during the systemstack call, receive a signal - signal requests a traceback of all goroutines The orignal G is still marked as _Grunning, so the traceback code refuses to print its stack. Fix by allowing traceback of Gs whose caller is on the same M as G is. G can't be modifying its stack if that is the case. Fixes #10546 Change-Id: I2bcea48c0197fbf78ab6fa080027cd80181083ad Reviewed-on: https://go-review.googlesource.com/9435 Reviewed-by: Ian Lance Taylor --- src/runtime/traceback.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 512ccd4e94..9f34e37ea4 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -627,7 +627,11 @@ func tracebackothers(me *g) { } print("\n") goroutineheader(gp) - if readgstatus(gp)&^_Gscan == _Grunning { + // Note: gp.m == g.m occurs when tracebackothers is + // called from a signal handler initiated during a + // systemstack call. The original G is still in the + // running state, and we want to print its stack. + if gp.m != g.m && readgstatus(gp)&^_Gscan == _Grunning { print("\tgoroutine running on other thread; stack unavailable\n") printcreatedby(gp) } else { -- 2.50.0