aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorEmmanuel T Odeke <emmanuel@orijtech.com>2017-02-18 03:03:32 -0700
committerEmmanuel Odeke <emmanuel@orijtech.com>2020-11-06 23:53:49 +0000
commit3a81338622eb5c8b94f11001855e2a68a9e36bed (patch)
tree86587279054d69ff4585e256f1435f1c44ca509f /src/runtime/testdata
parent5736eb0013cb8c9b67432c98b08f68e9f370810c (diff)
downloadgo-3a81338622eb5c8b94f11001855e2a68a9e36bed.tar.xz
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>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprog/deadlock.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprog/deadlock.go b/src/runtime/testdata/testprog/deadlock.go
index 105d6a5faa..0ee1557b13 100644
--- a/src/runtime/testdata/testprog/deadlock.go
+++ b/src/runtime/testdata/testprog/deadlock.go
@@ -20,6 +20,7 @@ func init() {
register("LockedDeadlock2", LockedDeadlock2)
register("GoexitDeadlock", GoexitDeadlock)
register("StackOverflow", StackOverflow)
+ register("StackOverflowTopAndBottomTraces", StackOverflowTopAndBottomTraces)
register("ThreadExhaustion", ThreadExhaustion)
register("RecursivePanic", RecursivePanic)
register("RecursivePanic2", RecursivePanic2)
@@ -85,6 +86,18 @@ func StackOverflow() {
f()
}
+func StackOverflowTopAndBottomTraces() {
+ var fi, gi func()
+ fi = func() {
+ gi()
+ }
+ gi = func() {
+ fi()
+ }
+ debug.SetMaxStack(10000)
+ fi()
+}
+
func ThreadExhaustion() {
debug.SetMaxThreads(10)
c := make(chan int)