Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/token: data race on FileSet.last #4345

Closed
dvyukov opened this issue Nov 5, 2012 · 11 comments
Closed

go/token: data race on FileSet.last #4345

dvyukov opened this issue Nov 5, 2012 · 11 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Nov 5, 2012

Revision 14791. Experimental windows race detector says:

WARNING: DATA RACE
Read by goroutine 15:
  runtime.lessstack()
      src/pkg/runtime/asm_amd64.s:247 +0x0
  go/token.(*FileSet).Position()
      src/pkg/go/token/position.go:403 +0x6f
  go/printer.(*printer).lineFor()
      src/pkg/go/printer/printer.go:148 +0xa3
  go/printer.(*printer).stmtList()
      src/pkg/go/printer/nodes.go:903 +0x1c7
  go/printer.(*printer).block()
      src/pkg/go/printer/nodes.go:917 +0x16d
  go/printer.(*printer).funcBody()
      src/pkg/go/printer/nodes.go:1473 +0x71a
  go/printer.(*printer).funcDecl()
      src/pkg/go/printer/nodes.go:1496 +0x3e2
  go/printer.(*printer).decl()
      src/pkg/go/printer/nodes.go:1506 +0xb5
  go/printer.(*printer).file()
      src/pkg/go/printer/nodes.go:1548 +0x3bd
  go/printer.(*printer).printNode()
      src/pkg/go/printer/printer.go:1054 +0x71f
  go/printer.(*Config).fprint()
      src/pkg/go/printer/printer.go:1192 +0xc1
  go/printer.(*Config).Fprint()
      src/pkg/go/printer/printer.go:1250 +0x8c
  go/printer.format()
      src/pkg/go/printer/printer_test.go:62 +0x3d4
  go/printer.runcheck()
      src/pkg/go/printer/printer_test.go:154 +0x779
  go/printer.func·005()
      src/pkg/go/printer/printer_test.go:172 +0x99

Previous write by goroutine 17:
  go/token.(*FileSet).file()
      src/pkg/go/token/position.go:379 +0x179
  go/token.(*FileSet).Position()
      src/pkg/go/token/position.go:403 +0x6f
  go/printer.(*printer).posFor()
      src/pkg/go/printer/printer.go:142 +0x5b
  go/printer.(*printer).nextComment()
      src/pkg/go/printer/printer.go:121 +0x21a
  go/printer.(*printer).printNode()
      src/pkg/go/printer/printer.go:1036 +0x4ab
  go/printer.(*Config).fprint()
      src/pkg/go/printer/printer.go:1192 +0xc1
  go/printer.(*Config).Fprint()
      src/pkg/go/printer/printer.go:1250 +0x8c
  go/printer.format()
      src/pkg/go/printer/printer_test.go:62 +0x3d4
  go/printer.runcheck()
      src/pkg/go/printer/printer_test.go:123 +0x1b1
  go/printer.func·005()
      src/pkg/go/printer/printer_test.go:172 +0x99

Goroutine 15 (running) created at:
  go/printer.check()
      src/pkg/go/printer/printer_test.go:174 +0x19f
  go/printer.TestFiles()
      src/pkg/go/printer/printer_test.go:209 +0x2ad
  testing.tRunner()
      src/pkg/testing/testing.go:301 +0x92

Goroutine 17 (running) created at:
  go/printer.check()
      src/pkg/go/printer/printer_test.go:174 +0x19f
  go/printer.TestFiles()
      src/pkg/go/printer/printer_test.go:209 +0x2ad
@dvyukov
Copy link
Member Author

dvyukov commented Nov 5, 2012

Comment 1:

Top frame of one of the stacks seems to be broken (lessstack).
But the report clearly points to that ad-hoc cache:
https://code.google.com/p/go/source/browse/src/pkg/go/token/position.go#379
maintained under *reader* lock:
https://code.google.com/p/go/source/browse/src/pkg/go/token/position.go#392

@bradfitz
Copy link
Contributor

bradfitz commented Nov 5, 2012

Comment 2:

If we had issue #2280 (Receiver-curried method expressions) resolved (which is currently
planned for Go1.1 I think?), then I think we could use a sync.Once here efficiently, as
Russ wants to make the expression "receiverVariable.Method" be no allocations.

@dvyukov
Copy link
Member Author

dvyukov commented Nov 6, 2012

Comment 3:

Do you mean that issue https://golang.org/issue/4343 ?
Do I get it right that func variables will be wider (2 words), and receiver.func() will
automatically convert to func()?

@griesemer
Copy link
Contributor

Comment 4:

Owner changed to @griesemer.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 5:

Labels changed: added size-m.

@dvyukov
Copy link
Member Author

dvyukov commented Dec 13, 2012

Comment 6:

Issue #4540 has been merged into this issue.

@davecheney
Copy link
Contributor

Comment 7:

Issue #4540 has been merged into this issue.

@alberts
Copy link
Contributor

alberts commented Dec 13, 2012

Comment 8:

"""
The race occurs when the the test takes longer than 10 seconds, so the fixture is marked
as a failure and starts the next one, which increases the likely hood of a data race on
the FileSet cache.
Reducing the timeout to 1 second and running `go test -race -cpu=4` triggers the race
almost immediately.
"""

@davecheney
Copy link
Contributor

Comment 9:

Proposal: https://golang.org/cl/6968044/

Owner changed to @davecheney.

@dvyukov
Copy link
Member Author

dvyukov commented Dec 19, 2012

Comment 10:

LGTM

@davecheney
Copy link
Contributor

Comment 11:

This issue was closed by revision 07e706f.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants