]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: print stack of G during a signal
authorKeith Randall <khr@golang.org>
Tue, 28 Apr 2015 21:53:19 +0000 (14:53 -0700)
committerKeith Randall <khr@golang.org>
Wed, 29 Apr 2015 19:25:10 +0000 (19:25 +0000)
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 <iant@golang.org>
src/runtime/traceback.go

index 512ccd4e947f2d6c343f38348e8c13912ecaf822..9f34e37ea4ec2939e1ae06f9392cf75d5dee15bc 100644 (file)
@@ -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 {