testing: t.Parallel in a subtest masks races with the outer test function #35670
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
The following test should reliably fail when run with
-race
, because it has multiple goroutines (viat.Parallel()
) that all read from the (unsynchronized, changing) loop variable.https://play.golang.org/p/nHo8MaTpS3o
However, because
t.Parallel
blocks the goroutine until the main test function returns, the race goes undetected: as far as the race detector is concerned, the program unambiguously meant to use only the last value of the loop variable.This unintended synchronization masks real bugs, such as the one reported in #35632.
#16520 requests a
vet
check that would detect this and similar cases, but perhaps there is something we can do within the implementation oft.Parallel
in order to expose these races too.CC @ianthehat @matloob @randall77
The text was updated successfully, but these errors were encountered: