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

runtime/race: false negative on fmt.Fprintf #6790

Closed
dvyukov opened this issue Nov 19, 2013 · 5 comments
Closed

runtime/race: false negative on fmt.Fprintf #6790

dvyukov opened this issue Nov 19, 2013 · 5 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Nov 19, 2013

The race in the following program is detected:
http://play.golang.org/p/tq5NFOk5_5

However a similar race is not detected in:
http://play.golang.org/p/veGvrmUKn7
@dvyukov
Copy link
Member Author

dvyukov commented Nov 19, 2013

Comment 2:

The problem is in the fmt package internal synchronized cache. When the goroutines are
executes sequentially one-by-one, the cache's mutex looks exactly as if it synchronizes
accesses to the buf.
If I increase number of goroutines to 1000 and runt with GOMAXPROCS=16, then the race is
detected -- some goroutines happen to run concurrently in the racy section of code.
sync.Pool would help here, because it may expose less synchronization to the race
detector.
Another counter-measure can be to introduce more random preemption when running under
race detector.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 3:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@dvyukov
Copy link
Member Author

dvyukov commented Jun 10, 2014

Comment 6:

This is fixed by sync.Pool changes. Now the race is detected reliably.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 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

3 participants