Commit 4b78c957 authored by Keith Randall's avatar Keith Randall

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/9435Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 4d1ab2d8
...@@ -627,7 +627,11 @@ func tracebackothers(me *g) { ...@@ -627,7 +627,11 @@ func tracebackothers(me *g) {
} }
print("\n") print("\n")
goroutineheader(gp) 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") print("\tgoroutine running on other thread; stack unavailable\n")
printcreatedby(gp) printcreatedby(gp)
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment