Skip to content

Conversation

@Gankra
Copy link
Collaborator

@Gankra Gankra commented Feb 20, 2023

I was mentally applying the rule that capacity can never exceed isize::MAX as a precondition BUT this is the code necessary for enforcing that! In fixing this I broke the fact that this code was subtly relying on that overflow to allow usize::MAX ZSTs to be allocated (by only allocating space for the header). ZSTs previously actually worked fine, as the garbage overflowed value was always wiped out by multiplying by 0 to get the array size. Now we need to handle it more explicitly.

(also a driveby explanation for why #42 happened)

I was mentally applying the rule that capacity can never exceed isize::MAX as a precondition BUT this is the code necessary for enforcing that! In fixing this I broke the fact that this code was subtly relying on that overflow to allow usize::MAX ZSTs to be allocated (by only allocating space for the header). ZSTs previously actually worked fine, as the garbage overflowed value was always wiped out by multiplying by 0 to get the array size. Now we need to handle it more explicitly.
@Gankra Gankra changed the title fix ZST handling and catch overflows better Handle overflows in capacities more Feb 20, 2023
@Gankra
Copy link
Collaborator Author

Gankra commented Feb 20, 2023

gonna merge this as, at very least, a strict improvement over the status quo

@Gankra Gankra merged commit 5bffb96 into main Feb 20, 2023
@Gankra
Copy link
Collaborator Author

Gankra commented Feb 20, 2023

0.2.12 published

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