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

Fix segfault with roaring64 intersect_with_range and empty bitmap #636

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

Dr-Emann
Copy link
Member

Fixes #635, and adds some tests

@SLieve, is this the right place to do this? The segfault under valgrind:

[ RUN      ] test_intersect_with_range
==648093== Invalid read of size 1
==648093==    at 0x12A894: art_node_iterator_lower_bound (art.c:1633)
==648093==    by 0x12AB9F: art_iterator_lower_bound (art.c:1696)
==648093==    by 0x120D2B: roaring64_iterator_move_equalorlarger (roaring64.c:2087)
==648093==    by 0x11E5DB: roaring64_bitmap_intersect_with_range (roaring64.c:1126)
==648093==    by 0x10F3F7: (anonymous namespace)::test_intersect_with_range(void**) (roaring64_unit.cpp:1058)
==648093==    by 0x15B74B: cmocka_run_one_test_or_fixture (cmocka.c:2801)
==648093==    by 0x15BA3F: cmocka_run_one_tests (cmocka.c:2909)
==648093==    by 0x15BF67: _cmocka_run_group_tests (cmocka.c:3040)
==648093==    by 0x112E17: main (roaring64_unit.cpp:1897)
==648093==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
==648093==
[  ERROR   ] --- Test failed with exception: Segmentation fault(11)
[  FAILED  ] test_intersect_with_range

The actual error seems to comes from art_node_iterator_lower_bound when passed a NULL node, not sure if this is the right place to guard, or if something lower down in the call chain should handle an empty bitmap better.

@Dr-Emann Dr-Emann requested review from lemire and SLieve June 26, 2024 02:13
@Dr-Emann

This comment was marked as outdated.

@Dr-Emann
Copy link
Member Author

Looks like I can get something similar with roaring64_iterator_move_equalorlarger on an empty bitmap directly as well.

@SLieve
Copy link
Contributor

SLieve commented Jun 26, 2024

I think the right place to fix this would be in art_iterator_lower_bound. My reasoning is that it would be useful for our internal code or the user to be able to (indirectly) call this on a possibly empty bitmap, without checking first.

@Dr-Emann Dr-Emann force-pushed the fix_635 branch 2 times, most recently from d292fd3 to 81c97d9 Compare June 27, 2024 02:31
src/art/art.c Show resolved Hide resolved
Copy link
Member

@lemire lemire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should merge and release 'soon'.

@Dr-Emann
Copy link
Member Author

Dr-Emann commented Jul 1, 2024

Ready when you are 👍

@lemire
Copy link
Member

lemire commented Jul 1, 2024

@Dr-Emann I am re-running a failed test which I do not expect to be related to this PR.

@Dr-Emann
Copy link
Member Author

Dr-Emann commented Jul 3, 2024

Anything else to do here? Would like to get this in and have a release with this in it.

@lemire lemire merged commit 9526ecf into master Jul 3, 2024
38 checks passed
@lemire
Copy link
Member

lemire commented Jul 3, 2024

Release upcoming.

@Dr-Emann Dr-Emann deleted the fix_635 branch July 3, 2024 21:52
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 this pull request may close these issues.

Roaring64 segfault empty bitmap intersect with range
3 participants