Fix data race on error recording in ErrSizedGroup - #14
Merged
Conversation
Previously, a worker stored the result of g.err.append(err) back into g.err while a canceled Go call read the same field outside the lock, which the race detector flags. MultiError.append mutates and returns its own receiver, so the assignment was redundant; dropping it makes the field write-once and removes the need for errLock, as MultiError is already thread safe on its own.
The cancel tests allowed 110 started goroutines, but 111 is reachable: 100 submitted before the cancellation, up to 10 running and one more waiting for the semaphore.
Coverage Report for CI Build 32187480544Coverage decreased (-0.03%) to 98.837%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
umputun
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, a worker stored the result of
g.err.append(err)back intog.errwhile aGocall which observed a canceled context read the same field outside the lock, and the race detector reports it as a data race.MultiError.appendmutates and returns its own receiver, so the assignment was redundant. After this change the field is only set in the constructor, which also makeserrLockunnecessary, asMultiErroris thread safe on its own.TestErrorSizedGroup_CancelWithActiveErrorscovers the case and fails undergo test -racewithout the fix.The two cancel tests allowed 110 started goroutines, but 111 is reachable: 100 submitted before the cancellation, up to 10 running and one more waiting for the semaphore. The bound is 120 now.