diff options
author | Keith Randall <khr@google.com> | 2019-09-17 14:10:50 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2019-10-18 06:02:08 +0000 |
commit | bc529506d21f4393af20becb7f50b6628b27c291 (patch) | |
tree | 83bfac32c78a51ec40eb87f3da04349f53c92127 /src/runtime/race | |
parent | d8e8d092f701fb6776dabd07be9d14cce99f2ee8 (diff) | |
download | go-bc529506d21f4393af20becb7f50b6628b27c291.tar.gz go-bc529506d21f4393af20becb7f50b6628b27c291.zip |
runtime/race: add test for midstack inlining
Add test to make sure we get the right traceback when mid-stack inlining.
Update #33309
Change-Id: I23979cbe6b12fad105dbd26698243648aa86a354
Reviewed-on: https://go-review.googlesource.com/c/go/+/195984
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Diffstat (limited to 'src/runtime/race')
-rw-r--r-- | src/runtime/race/output_test.go | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go index 019ad5806e..d3e7762175 100644 --- a/src/runtime/race/output_test.go +++ b/src/runtime/race/output_test.go @@ -24,7 +24,7 @@ func TestOutput(t *testing.T) { t.Fatal(err) } defer os.RemoveAll(pkgdir) - out, err := exec.Command(testenv.GoToolPath(t), "install", "-race", "-pkgdir="+pkgdir, "-gcflags=all=-l", "testing").CombinedOutput() + out, err := exec.Command(testenv.GoToolPath(t), "install", "-race", "-pkgdir="+pkgdir, "testing").CombinedOutput() if err != nil { t.Fatalf("go install -race: %v\n%s", err, out) } @@ -56,8 +56,8 @@ func TestOutput(t *testing.T) { if err := f.Close(); err != nil { t.Fatalf("failed to close file: %v", err) } - // Pass -l to the compiler to test stack traces. - cmd := exec.Command(testenv.GoToolPath(t), test.run, "-race", "-pkgdir="+pkgdir, "-gcflags=all=-l", src) + + cmd := exec.Command(testenv.GoToolPath(t), test.run, "-race", "-pkgdir="+pkgdir, src) // GODEBUG spoils program output, GOMAXPROCS makes it flaky. for _, env := range os.Environ() { if strings.HasPrefix(env, "GODEBUG=") || @@ -218,6 +218,52 @@ func main() { main\.main\.func1\(\) .*/main.go:7`}, + // Test for https://golang.org/issue/33309 + {"midstack_inlining_traceback", "run", "linux", "atexit_sleep_ms=0", ` +package main + +var x int + +func main() { + c := make(chan int) + go f(c) + x = 1 + <-c +} + +func f(c chan int) { + g(c) +} + +func g(c chan int) { + h(c) +} + +func h(c chan int) { + c <- x +} +`, `================== +WARNING: DATA RACE +Read at 0x[0-9,a-f]+ by goroutine [0-9]: + main\.h\(\) + .+/main\.go:22 \+0x[0-9,a-f]+ + main\.g\(\) + .+/main\.go:18 \+0x[0-9,a-f]+ + main\.f\(\) + .+/main\.go:14 \+0x[0-9,a-f]+ + +Previous write at 0x[0-9,a-f]+ by main goroutine: + main\.main\(\) + .+/main\.go:9 \+0x[0-9,a-f]+ + +Goroutine [0-9] \(running\) created at: + main\.main\(\) + .+/main\.go:8 \+0x[0-9,a-f]+ +================== +Found 1 data race\(s\) +exit status 66 +`}, + // Test for https://golang.org/issue/17190 {"external_cgo_thread", "run", "linux", "atexit_sleep_ms=0", ` package main |