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.
The text was updated successfully, but these errors were encountered: