diff options
author | Cherry Zhang <cherryyz@google.com> | 2018-12-30 23:53:27 -0500 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2019-01-07 20:36:58 +0000 |
commit | 902b1f605908cc412e418ede6821fd8122979297 (patch) | |
tree | b947f175fecbc2d186daec444d4e570014e84de7 | |
parent | af3c4809675d1f8c0a96a6593795ce89c52ead2a (diff) | |
download | go-902b1f605908cc412e418ede6821fd8122979297.tar.gz go-902b1f605908cc412e418ede6821fd8122979297.zip |
runtime/pprof: add a test for gccgo bug #29448
With gccgo, if a profiling signal arrives in certain time during
traceback, it may crash or hang. The fix is CL 156037 and
CL 156038. This CL adds a test.
Updates #29448.
Change-Id: Idb36af176b4865b8fb31a85cad185ed4c07ade0c
Reviewed-on: https://go-review.googlesource.com/c/156018
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r-- | src/runtime/pprof/pprof_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index e395d15310..7c6043ffdb 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -1010,3 +1010,38 @@ func TestAtomicLoadStore64(t *testing.T) { atomic.StoreUint64(&flag, 1) <-done } + +func TestTracebackAll(t *testing.T) { + // With gccgo, if a profiling signal arrives at the wrong time + // during traceback, it may crash or hang. See issue #29448. + f, err := ioutil.TempFile("", "proftraceback") + if err != nil { + t.Fatalf("TempFile: %v", err) + } + defer os.Remove(f.Name()) + defer f.Close() + + if err := StartCPUProfile(f); err != nil { + t.Fatal(err) + } + defer StopCPUProfile() + + ch := make(chan int) + defer close(ch) + + count := 10 + for i := 0; i < count; i++ { + go func() { + <-ch // block + }() + } + + N := 10000 + if testing.Short() { + N = 500 + } + buf := make([]byte, 10*1024) + for i := 0; i < N; i++ { + runtime.Stack(buf, true) + } +} |