Repository navigation
[NativeAOT-LLVM] Fix array allocators - #2342
Merged
Merged
Conversation
There were two bugs: 1) The overflow detection wasn't working properly due to C++ rules. The "align up" arithmetic was being performed in 32 bit integers. 2) When we overflow on 32 bit, we are supposed to OOM, not actually throw an overflow exception. Fix both issues by simply delegating to the slow path helpers when we have large (65K+ elements) arrays.
SingleAccretion
marked this pull request as ready for review
July 16, 2023 09:59
Author
|
@dotnet/nativeaot-llvm |
Actually, I question the correctness of this code as well, but let's leave it be for now.
SingleAccretion
force-pushed
the
Arr-Alloc
branch
from
July 17, 2023 15:35
4f82f4a to
de861fc
Compare
Member
|
It would be nice to upstream these changes to https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/Runtime/portable.cpp |
jkotas
reviewed
Jul 18, 2023
Comment on lines
252
to
255
| if (paddedSize > SIZE_MAX - 12) | ||
| { | ||
| ASSERT_UNCONDITIONALLY("NYI"); // TODO: Throw overflow | ||
| ThrowOverflowException(pShadowStack, pArrayEEType); | ||
| } |
Member
There was a problem hiding this comment.
This check is dead code now that the large element sizes are handled as early out above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There were two bugs:
The "align up" arithmetic was being performed in 32 bit integers.
throw an overflow exception.
Fix both issues by simply delegating to the slow path helpers when we have large (65K+ elements) arrays.
With this fix, a small libraries test suite runs to completion on my machine: