testing: t.Parallel in a subtest masks races with the outer test function #35670
Labels
Milestone
Comments
Hmm, good point. I don't actually think |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: