-
Notifications
You must be signed in to change notification settings - Fork 268
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: add null checks to roaring64 #633
base: master
Are you sure you want to change the base?
Conversation
@madscientist Can you help review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, though I wonder about the cost/benefit of adding additional code to handle a subset of OOM cases. As mentioned, this will not catch everything but on the other hand it does make the code harder to reason about. For example we need to keep track of what to free in the malloc failure case.
I agree with @SLieve : the code looks fine but I still wonder whether we've hit upon the correct approach. |
I will leave this open. I am not at all pushing to get this merged. |
What do you mean here? Possible temporaries aside from the OTOH, maybe there's a way to do the allocations in one place and find the allocation error once, separate from the core logic, to make the logic itself easier to reason about? |
Yes, I mean any temporaries. Of course |
I think it should at least be a global decision, and a documented one, given we don't always use the system allocator. |
@Oppen Sounds sensible. I have no strong opinion and I am eager to know what people think. I will setup an issue. |
Unless we can get fuzzing set up to deterministically randomly return null from the allocator while doing operations, I won't have a ton of confidence in trying to handle nulls |
In the case of the memory is full, alloc will return NULL, the application will core dump without this null checking. And there is no other way to avoid this from happening. Similar in roaring.c, there is a null check after each roaring_malloc. I am strongly suggest to merge this PR. |
@qijiax The reason I am not merging this PR (which I wrote) is that we have no reason to believe that it solves the problem. That is we don't know what this PR will do when we run out of memory. We have no testing, no analysis. So we are basically working on assumptions. |
@lemire I tried to set the global roaring_alloc and throw exception when running out of mem, but can not solve all the problem. Because I have no way to free the memory that is successfully allocated. |
Pull request invited. |
@lemire Any updates on this discussion? Will you merge this PR soon? Thanks~ |
Please read the comments on this PR (see above comments). It does not seem to get the massive support I'd want. So I am waiting for either a better solution or more agreement. |
Might help with #630
This is likely not a perfect fix.