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

Separately track bitarray capacity #2349

Closed
wants to merge 1 commit into from

Conversation

etang-cw
Copy link
Contributor

Fixes a bug where when resizing from > 64 bits to ≤ 64 bits, BitArray wouldn't realize that it was going to go from interpreting _data as a pointer to interpreting it as bits, and would fail to both free the pointer and copy its contents into _data, resulting in a memory leak, loss of the data in the BitArray, and a desync with the _lowestNeverClearedBitIndex and _clearedSectionCount variables. In the worst case scenario, such a resize when _lowestNeverClearedBitIndex was 0 would make future calls to setAllBits not set all bits, even though many bits were not set.

@billhollings
Copy link
Contributor

Thanks for much for submitting this. And good catch and research!

This issue was causing the crash in #2271.

I've been sitting on an overhaul of BitArray that fixes this issue, and a few other things, including performance, because I didn't want to include a hefty change right before an SDK release, in case it unexpectedly affected other things.

So it's my bad that it's not out there yet. Sorry about that. I'll put that out in the few days.

@billhollings
Copy link
Contributor

Superseded by PR #2355.

@etang-cw etang-cw deleted the FixBitArray branch November 25, 2024 17:46
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.

2 participants