]> Cypherpunks repositories - gostls13.git/commit
runtime: make stack traces of endless recursion print only top and bottom 50
authorEmmanuel T Odeke <emmanuel@orijtech.com>
Sat, 18 Feb 2017 10:03:32 +0000 (03:03 -0700)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Fri, 6 Nov 2020 23:53:49 +0000 (23:53 +0000)
commit3a81338622eb5c8b94f11001855e2a68a9e36bed
tree86587279054d69ff4585e256f1435f1c44ca509f
parent5736eb0013cb8c9b67432c98b08f68e9f370810c
runtime: make stack traces of endless recursion print only top and bottom 50

This CL makes it so that instead of printing massive stack traces during
endless recursion, which spams users and aren't useful, it now prints out
the top and bottom 50 frames. If the number of frames <= 100
(_TracebackMaxFrames), we'll just print all the frames out.

Modified gentraceback to return counts of:
* ntotalframes
* nregularframes
which allows us to get accurate counts of the various kinds of frames.

While here, also fixed a bug that resulted from CL 37222, in which we
no longer accounted for decrementing requested frame skips, and assumed
that when printing, that skip would always be 0. The fix is instead to add
precondition that we'll only print if skip <= 0, but also decrement skip
as we iterate.

Fixes #7181.
Fixes #24628.

Change-Id: Ie31ec6413fdfbe43827b254fef7d99ea26a5277f
Reviewed-on: https://go-review.googlesource.com/c/go/+/37222
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
src/runtime/crash_test.go
src/runtime/testdata/testprog/deadlock.go
src/runtime/traceback.go