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

BitArray throws IndexOutOfRangeException when unmet shrink threshold #29626

Closed
bricelam opened this issue May 21, 2019 · 3 comments · Fixed by dotnet/corefx#37876
Closed

BitArray throws IndexOutOfRangeException when unmet shrink threshold #29626

bricelam opened this issue May 21, 2019 · 3 comments · Fixed by dotnet/corefx#37876
Labels
area-System.Collections blocking Marks issues that we want to fast track in order to unblock other important work
Milestone

Comments

@bricelam
Copy link
Contributor

var left = new BitArray(64);
var right = new BitArray(32);

// NB: Since the shrink threshold (256) isn't met, the underlying int array isn't resized
left.Length = 32;

// System.IndexOutOfRangeException: Index was outside the bounds of the array.
left.Or(right);

The Or operation (and probably others) assume that the length of underlying int arrays of both operands are equal. But this isn't the case when the arrays aren't actually resized when the BitArray length changes.

cc @ajcvickers @Pilchie

@Pilchie
Copy link
Member

Pilchie commented May 22, 2019

@danmosemsft ?

@danmoseley
Copy link
Member

@tannergooding maybe one you could look at?

@Gnbrkm41
Copy link
Contributor

I think I can submit a PR for this. Feel free to reject if it's undesirable 😁

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 3.0 milestone Feb 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Collections blocking Marks issues that we want to fast track in order to unblock other important work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants