]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: fix getcallerpc args
authorDmitry Vyukov <dvyukov@google.com>
Thu, 25 Feb 2016 18:16:18 +0000 (19:16 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Thu, 25 Feb 2016 18:57:28 +0000 (18:57 +0000)
Change-Id: I6b14b8eecf125dd74bd40f4e7fff6b49de150e42
Reviewed-on: https://go-review.googlesource.com/19897
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/race/output_test.go
src/runtime/string.go

index 0c71a019dd59dd9f70102d423e39a95100a6bd9b..27d9efb6871eaca2d13f708f7c418407a6f7181e 100644 (file)
@@ -180,4 +180,21 @@ func TestFail(t *testing.T) {
 PASS
 Found 1 data race\(s\)
 FAIL`},
+
+       {"slicebytetostring_pc", "run", "atexit_sleep_ms=0", `
+package main
+func main() {
+       done := make(chan string)
+       data := make([]byte, 10)
+       go func() {
+               done <- string(data)
+       }()
+       data[0] = 1
+       <-done
+}
+`, `
+  runtime\.slicebytetostring\(\)
+      .*/runtime/string\.go:.*
+  main\.main\.func1\(\)
+      .*/main.go:7`},
 }
index dd04bda04ba3cb37833d1201c3defc70ec035310..5dc7e0295af770a108df6534d0b0846850866a76 100644 (file)
@@ -84,7 +84,7 @@ func slicebytetostring(buf *tmpBuf, b []byte) string {
        if raceenabled && l > 0 {
                racereadrangepc(unsafe.Pointer(&b[0]),
                        uintptr(l),
-                       getcallerpc(unsafe.Pointer(&b)),
+                       getcallerpc(unsafe.Pointer(&buf)),
                        funcPC(slicebytetostring))
        }
        if msanenabled && l > 0 {
@@ -189,7 +189,7 @@ func slicerunetostring(buf *tmpBuf, a []rune) string {
        if raceenabled && len(a) > 0 {
                racereadrangepc(unsafe.Pointer(&a[0]),
                        uintptr(len(a))*unsafe.Sizeof(a[0]),
-                       getcallerpc(unsafe.Pointer(&a)),
+                       getcallerpc(unsafe.Pointer(&buf)),
                        funcPC(slicerunetostring))
        }
        if msanenabled && len(a) > 0 {