-
Notifications
You must be signed in to change notification settings - Fork 215
Closed
Labels
area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation.NET runtime optimized for ahead of time compilation
Description
We have System.Runtime tests that test allocating the maximally supported arrays. We throw an OutOfMemoryException for them. Likely because this code:
runtimelab/src/coreclr/nativeaot/Runtime/gcrhenv.cpp
Lines 239 to 263 in 8fac0a8
| // higher limit for array of bytes (or one byte structs) for backward compatibility. | |
| // Keep in sync with Array.MaxArrayLength in BCL. | |
| if (cbSize > MaxByteArrayLength /* note: comparing allocation size with element count */) | |
| { | |
| // Ensure the above if check covers the minimal interesting size | |
| static_assert(MaxByteArrayLength < (uint64_t)MaxArrayLength * 2, ""); | |
| if (pEEType->IsArray()) | |
| { | |
| if (pEEType->get_ComponentSize() != 1) | |
| { | |
| size_t elementCount = (cbSize - pEEType->get_BaseSize()) / pEEType->get_ComponentSize(); | |
| if (elementCount > MaxArrayLength) | |
| return NULL; | |
| } | |
| else | |
| { | |
| size_t elementCount = cbSize - pEEType->get_BaseSize(); | |
| if (elementCount > MaxByteArrayLength) | |
| return NULL; | |
| } | |
| } | |
| } | |
| if (cbSize >= RH_LARGE_OBJECT_SIZE) |
Is checking the allocation size instead of element count. Allocation size has already been aligned up.
Metadata
Metadata
Assignees
Labels
area-NativeAOT-coreclr.NET runtime optimized for ahead of time compilation.NET runtime optimized for ahead of time compilation