Fix non-atomic refcount decrement - #859
Merged
lemire merged 1 commit intoAug 8, 2026
Merged
Conversation
Member
|
Seems like an obvious defect to me. Merging. |
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.
Summary
CROARING_ATOMIC_IMPL_NONERoot cause and impact
croaring_refcount_dec()decremented*valbut returnedval == 0. Since callers pass a valid pointer, the function could never report that the final reference had been released. This prevents shared containers from being freed and makes extraction take an unnecessary copy path when the non-atomic fallback is selected.Fixes #858.
This was found while reviewing the vendored CRoaring integration in redis/redis#15331.
Validation
mastercmake -S . -B build-release -DCMAKE_BUILD_TYPE=Release -DENABLE_ROARING_TESTS=ONcmake --build build-release -j2ctest --test-dir build-release --output-on-failure— 27/27 passedgit diff --checkThe Docker-based formatting helper was unavailable locally; formatting remains covered by CI.
Prepared with Codex assistance under contributor direction; the bug was reproduced and the complete test suite above was run before opening this draft.