Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with shift #104

Closed
SamHames opened this issue Jan 3, 2024 · 2 comments · Fixed by #102
Closed

Issues with shift #104

SamHames opened this issue Jan 3, 2024 · 2 comments · Fixed by #102

Comments

@SamHames
Copy link
Contributor

SamHames commented Jan 3, 2024

Example 1

I found a weird bug (or bugs) with shifting - I think I can replicate this first one with croaring alone though so I will raise an issue there to confirm. The failures happen with both the current croaring and the latest release (v2.1.0).

import pyroaring
x = pyroaring.BitMap(range(0, 9000, 2)).shift(64000)
y = pyroaring.BitMap.deserialize(x.serialize())
print(y)
print(set(y))

The output should be (64000, 64002, 64004, ...), but you don't even get a set:

BitMap([    0,
            0,
            0,
            0,
            0,
        ...
        87381,
        87381,
        87381,
        87381,
        87381])
{0, 65536, 87381}

Example 2

Another case that fails with a segfault, but only when copy_on_write is enabled (transcribed from the test case - hypothesis doesn't deal well with a segfault). The segfault happens in the final comparison.

from pyroaring import BitMap

cls = BitMap  # Also fails with FrozenBitMap
values = range(67335, 68618, 8) 
offset = 33554432 
cow = True  # Doesn't fail when this is off

bm_before = cls(values, copy_on_write=cow)
bm_copy = cls(bm_before)
bm_after = bm_before.shift(offset)
assert(bm_before == bm_copy)
expected = cls([val+offset for val in values if val+offset in range(0, 2**32)], copy_on_write=cow)
assert(bm_after == expected)
@lemire
Copy link
Contributor

lemire commented Jan 3, 2024

I recommend updating to 2.1.1:
https://github.com/RoaringBitmap/CRoaring/releases/tag/v2.1.1

It should fix the issue.

@lemire
Copy link
Contributor

lemire commented Jan 4, 2024

Fixed the second bug in the next release

https://github.com/RoaringBitmap/CRoaring/releases/tag/v2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants