Repository navigation
Conversation
Concurrent Clone calls wrote the source needCopyOnWrite flags at the same time. The mark is still required so a later write copies shared containers, and it now runs under cowMu.
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.
Description
Concurrent Clone of one copy-on-write bitmap writes the source needCopyOnWrite slice. Two goroutines that only clone the same bitmap race on that slice, even when nobody else writes. The mark stays, because a later write still has to copy containers that are shared with the source. The source mark now runs under a mutex.
Type of Change
Changes Made
What was changed?
Why was it changed?
Bitmap.Clone()data race on copy-on-write bitmaps (no writers) #528. markAllAsNeedingCopyOnWrite writes the source on every copy-on-write clone, so concurrent clones are a data race.How was it changed?
Testing
Please add a unit test if you are fixing a bug.
go test -race -run TestConcurrentCloneOfCOWBitmapfailed before the lock with a data race in markAllAsNeedingCopyOnWrite. The same test passes after the lock, in the root package and in roaring64. A write to the clone does not show up on the source.go test -count=1 -timeout 180s . ./roaring64 ./BitSliceIndexingpassed.go vetstill reports the existing ReadFrom signature mismatch in roaring.go. This change does not touch that method.Formatting
go fmtwas run on the changed Go files.Fuzzing
The serialization format is unchanged, so I did not regenerate the SMAT corpus or run the 300s fuzzer.
Performance Impact
The mutex is taken only around the flag writes during a copy-on-write clone. Container copies are unchanged. I did not run the benchmark suite.
Breaking Changes
None.
Related Issues
Fixes #528