diff options
author | Cherry Zhang <cherryyz@google.com> | 2019-11-14 21:34:35 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2019-11-27 01:30:32 +0000 |
commit | 0f251028585e052a3d34dcce83b05d8aa9ba170e (patch) | |
tree | ac9f64fd93fb23a8e00c97298056214e4f2021d8 /src/runtime/crash_test.go | |
parent | b2482e481722357c6daa98ef074d8eaf8ac4baf3 (diff) | |
download | go-0f251028585e052a3d34dcce83b05d8aa9ba170e.tar.gz go-0f251028585e052a3d34dcce83b05d8aa9ba170e.zip |
runtime: print more information on stack overflow
Print the current SP and (old) stack bounds when the stack grows
too large. This helps to identify the problem: whether a large
stack is used, or something else goes wrong.
For #35470.
Change-Id: I34a4064d5c7280978391d835e171b90d06f87222
Reviewed-on: https://go-review.googlesource.com/c/go/+/207351
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/runtime/crash_test.go')
-rw-r--r-- | src/runtime/crash_test.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go index 6c3127fa75..5333b60646 100644 --- a/src/runtime/crash_test.go +++ b/src/runtime/crash_test.go @@ -204,9 +204,23 @@ func TestGoexitDeadlock(t *testing.T) { func TestStackOverflow(t *testing.T) { output := runTestProg(t, "testprog", "StackOverflow") - want := "runtime: goroutine stack exceeds 1474560-byte limit\nfatal error: stack overflow" - if !strings.HasPrefix(output, want) { - t.Fatalf("output does not start with %q:\n%s", want, output) + want := []string{ + "runtime: goroutine stack exceeds 1474560-byte limit\n", + "fatal error: stack overflow", + // information about the current SP and stack bounds + "runtime: sp=", + "stack=[", + } + if !strings.HasPrefix(output, want[0]) { + t.Errorf("output does not start with %q", want[0]) + } + for _, s := range want[1:] { + if !strings.Contains(output, s) { + t.Errorf("output does not contain %q", s) + } + } + if t.Failed() { + t.Logf("output:\n%s", output) } } |