FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
runtime: use runtime·callers when racefuncenter's pc is on the heap.

Please review this at http://codereview.appspot.com/6821069/

Affected files:
M src/pkg/runtime/race.c


Index: src/pkg/runtime/race.c
===================================================================
--- a/src/pkg/runtime/race.c
+++ b/src/pkg/runtime/race.c
@@ -74,7 +74,10 @@
{
// If the caller PC is lessstack, use slower runtime·callers
// to walk across the stack split to find the real caller.
- if(pc == (uintptr)runtime·lessstack)
+ // Same thing if the PC is on the heap, which should be a
+ // closure trampoline.
+ if(pc == (uintptr)runtime·lessstack ||
+ (pc >= (uintptr)runtime·mheap.arena_start && pc <
(uintptr)runtime·mheap.arena_used))
runtime·callers(2, &pc, 1);

m->racecall = true;

Search Discussions

  • Remyoudompheng at Nov 1, 2012 at 8:12 pm
    The race report for this example became ugly:

    func main2() {
    var a int
    ch := make(chan int, 1)
    f1 := func() { a = 1 }
    f2 := func() { f1() }
    f3 := func() { a = 2; ch <- 0 }
    go f3()
    f2()
    <-ch
    }

    Before:
    ==================
    WARNING: DATA RACE
    Write by goroutine 3:
    main.func·004()
    /opt/remy/go.pristine3/machin.go:27 +0x33
    ??()
    -:0 +0x400370a3

    Previous write by goroutine 0:
    main.func·002()
    /opt/remy/go.pristine3/machin.go:25 +0x33
    ??()
    -:0 +0x40037021
    ??()
    -:0 +0x40037061
    main.main()
    /opt/remy/go.pristine3/machin.go:35 +0x2e
    runtime.main()
    /opt/remy/go.pristine3/src/pkg/runtime/proc.c:248 +0x91

    Goroutine 3 (running) created at:
    main.main2()
    /opt/remy/go.pristine3/machin.go:28 +0x11a
    main.main()
    /opt/remy/go.pristine3/machin.go:35 +0x2e
    runtime.main()
    /opt/remy/go.pristine3/src/pkg/runtime/proc.c:248 +0x91

    ==================

    After:
    ==================
    WARNING: DATA RACE
    Write by goroutine 3:
    main.func·004()
    /opt/remy/go.pristine3/machin.go:27 +0x33

    Previous write by goroutine 0:
    main.func·002()
    /opt/remy/go.pristine3/machin.go:25 +0x33
    main.func·003()
    /opt/remy/go.pristine3/machin.go:26 +0x3c
    main.main2()
    /opt/remy/go.pristine3/machin.go:29 +0x122
    main.main()
    /opt/remy/go.pristine3/machin.go:35 +0x2e
    runtime.main()
    /opt/remy/go.pristine3/src/pkg/runtime/proc.c:248 +0x91

    Goroutine 3 (running) created at:
    main.main2()
    /opt/remy/go.pristine3/machin.go:28 +0x11a
    main.main()
    /opt/remy/go.pristine3/machin.go:35 +0x2e
    runtime.main()
    /opt/remy/go.pristine3/src/pkg/runtime/proc.c:248 +0x91

    ==================


    http://codereview.appspot.com/6821069/
  • Remyoudompheng at Nov 6, 2012 at 11:21 pm
  • Rsc at Nov 7, 2012 at 2:20 pm
  • Remyoudompheng at Nov 7, 2012 at 8:35 pm
    *** Submitted as
    http://code.google.com/p/go/source/detail?r=c37ad3c7cb80 ***

    runtime: use runtime·callers when racefuncenter's pc is on the heap.

    R=golang-dev, rsc
    CC=golang-dev
    http://codereview.appspot.com/6821069


    http://codereview.appspot.com/6821069/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 1, '12 at 8:10p
activeNov 7, '12 at 8:35p
posts5
users2
websitegolang.org

2 users in discussion

Remyoudompheng: 4 posts Rsc: 1 post

People

Translate

site design / logo © 2021 Grokbase