diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2015-02-07 15:31:18 +0300 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2015-02-11 10:39:48 +0000 |
| commit | 59495e8dfda0cfc1fa527337b2fed8a8099137dc (patch) | |
| tree | d102f214df99efde953da072c29cc9bf86a98026 /src/runtime/traceback.go | |
| parent | 84e256753744e765e4a31b48e2a641eecd4d01f1 (diff) | |
| download | go-59495e8dfda0cfc1fa527337b2fed8a8099137dc.tar.xz | |
runtime: never show system goroutines in traceback
Fixes #9791
g.issystem flag setup races with other code wherever we set it.
Even if we set both in parent goroutine and in the system goroutine,
it is still possible that some other goroutine crashes
before the flag is set. We could pass issystem flag to newproc1,
but we start all goroutines with go nowadays.
Instead look at g.startpc to distinguish system goroutines (similar to topofstack).
Change-Id: Ia3467968dee27fa07d9fecedd4c2b00928f26645
Reviewed-on: https://go-review.googlesource.com/4113
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/traceback.go')
| -rw-r--r-- | src/runtime/traceback.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 6c87d7e2e4..8c31c5abad 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -39,6 +39,11 @@ var ( mstartPC uintptr rt0_goPC uintptr sigpanicPC uintptr + runfinqPC uintptr + backgroundgcPC uintptr + bgsweepPC uintptr + forcegchelperPC uintptr + timerprocPC uintptr systemstack_switchPC uintptr externalthreadhandlerp uintptr // initialized elsewhere @@ -56,6 +61,11 @@ func tracebackinit() { mstartPC = funcPC(mstart) rt0_goPC = funcPC(rt0_go) sigpanicPC = funcPC(sigpanic) + runfinqPC = funcPC(runfinq) + backgroundgcPC = funcPC(backgroundgc) + bgsweepPC = funcPC(bgsweep) + forcegchelperPC = funcPC(forcegchelper) + timerprocPC = funcPC(timerproc) systemstack_switchPC = funcPC(systemstack_switch) } @@ -606,7 +616,7 @@ func tracebackothers(me *g) { lock(&allglock) for _, gp := range allgs { - if gp == me || gp == g.m.curg || readgstatus(gp) == _Gdead || gp.issystem && level < 2 { + if gp == me || gp == g.m.curg || readgstatus(gp) == _Gdead || isSystemGoroutine(gp) && level < 2 { continue } print("\n") @@ -631,3 +641,14 @@ func topofstack(f *_func) bool { pc == rt0_goPC || externalthreadhandlerp != 0 && pc == externalthreadhandlerp } + +// isSystemGoroutine returns true if the goroutine g must be omitted in +// stack dumps and deadlock detector. +func isSystemGoroutine(gp *g) bool { + pc := gp.startpc + return pc == runfinqPC && !fingRunning || + pc == backgroundgcPC || + pc == bgsweepPC || + pc == forcegchelperPC || + pc == timerprocPC +} |
