roaring64: honor copy-on-write in Bitmap.Or#525
Open
ostafen wants to merge 1 commit into
Open
Conversation
When two bitmaps share a container key, the in-place Or was calling getContainerAtIndex, which returns the raw container without consulting needCopyOnWrite. If rb's container at that index was shared with another bitmap (e.g. produced by Clone() on a CoW-enabled bitmap), the Or would mutate the shared container in place and silently corrupt the other bitmap. Switch to getWritableContainerAtIndex, which clones the container first when needCopyOnWrite is set. This matches what the sibling AndNot/And methods in the same file already do, and what the 32-bit Bitmap.Or does via getUnionedWritableContainer.
Member
|
Running tests. |
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
When two bitmaps share a container key, the in-place Or was calling getContainerAtIndex, which returns the raw container without consulting needCopyOnWrite. If rb's container at that index was shared with another bitmap (e.g. produced by Clone() on a CoW-enabled bitmap), the Or would mutate the shared container in place and silently corrupt the other bitmap.
Type of Change
Changes Made
Switch to getWritableContainerAtIndex, which clones the container first when needCopyOnWrite is set. This matches what the sibling AndNot/And methods in the same file already do, and what the 32-bit Bitmap.Or does via getUnionedWritableContainer.
Testing
Added a unit test reproducing the issue that fails without the fix.
You must run
Formatting
Please run
Fuzzing
Please run our fuzzer on your changes.
You should see a directory
workdircreated with initial corpus files.Adjust
-fuzztimeas needed for longer or shorter runs. If crashes are found,check the test output and the reproducer files in the
workdirdirectory.You may copy the reproducers to roaring_tests.go
Performance Impact
If applicable, describe any performance implications of these changes and include benchmark results.
Running Benchmarks
This project includes comprehensive benchmarks. Please run relevant benchmarks before and after your changes:
Basic Benchmarks
Parallel Benchmarks
Real Data Benchmarks
Benchmark Results Format
Please include before/after results in the following format:
Performance Analysis
Breaking Changes
If this PR introduces breaking changes, please describe them and the migration path:
Related Issues
Fixes # (issue number)
Related to # (issue number)
Additional Notes
Any additional information or context about this pull request.