Skip to content

runtime/race: needs fix for new func representation #4885

@remyoudompheng

Description

@remyoudompheng
What steps will reproduce the problem?
1. go run -race this:

package main

import "runtime"

func F(j *int) {
      for i := 0; i < 10; i++ {
            *j = *j + 1
      }
}


func main() {
      var j int
      go func() { F(&j) }()
      go func() { F(&j) }()
      runtime.Goexit()
}

What is the expected output? What do you see instead?

Expected:

WARNING: DATA RACE
Write by goroutine 3:
  main.F()
      /tmp/test.go:7 +0x41
  main.func·002()
      /tmp/test.go:15 +0x32

Previous write by goroutine 2:
  main.F()
      /tmp/test.go:7 +0x41
  main.func·001()
      /tmp/test.go:14 +0x32

Goroutine 3 (running) created at:
  main.main()
      /tmp/test.go:15 +0x71
  runtime.main()
      /opt/remy/go.clean/src/pkg/runtime/proc.c:255 +0x8e

Goroutine 2 (finished) created at:
  main.main()
      /tmp/test.go:14 +0x5a
  runtime.main()
      /opt/remy/go.clean/src/pkg/runtime/proc.c:255 +0x8e

Got:

WARNING: DATA RACE
Write by goroutine 4:
  main.F()
      /tmp/test.go:7 +0x41
  ??()
      -:0 +0x231df
  ??()
      -:0 +0x231df

Previous write by goroutine 3:
  main.F()
      /tmp/test.go:7 +0x41
  ??()
      -:0 +0x231ef
  ??()
      -:0 +0x231ef

Goroutine 4 (running) created at:
  main.main()
      /tmp/test.go:15 +0xef
  ??()
      -:0 +0x20ce1ef7

Goroutine 3 (finished) created at:
  main.main()
      /tmp/test.go:14 +0x99
  ??()
      -:0 +0x20ce1ef7


Please use labels and text to provide additional information.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions