Uh oh!
There was an error while loading. Please reload this page.
Align NativeAOT array element size limit - #130019
Conversation
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
MichalStrehovsky
commented
Jun 30, 2026
/azp run runtime-nativeaot-outerloop, runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Aligns NativeAOT’s array element-size validation with the runtime limit so that value-type array elements of exactly 65,535 bytes are accepted (matching CoreCLR behavior at the boundary). This avoids rejecting a size that still fits the GCDesc/component-size encodings used by the NativeAOT toolchain.
Changes:
- Adjusted NativeAOT type loadability validation for arrays to reject only element sizes greater than
ushort.MaxValue. - Added a new InlineArray-focused regression test project and test that exercises using an
[InlineArray(65535)]struct as an array element type.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.Validation.cs | Updates array element-size check from >= ushort.MaxValue to > ushort.MaxValue, allowing the 65,535-byte boundary. |
| src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.csproj | Adds a new standalone test project for the regression scenario. |
| src/tests/Loader/classloader/InlineArray/MaxArrayElementSize.cs | Adds a test covering [InlineArray(65535)] as an array element type (size + successful array construction). |
hez2010
commented
Jun 30, 2026
Can this be backported to .NET 10 as well? |
jkotas
commented
Jun 30, 2026
This does not meet the bar for backport. |
MichalStrehovsky
commented
Jul 1, 2026
/ba-g the alpine libatomic issue is known |
Uh oh!
There was an error while loading. Please reload this page.
### Description
NativeAOT rejected array element value types of exactly 65,535 bytes,
while CoreCLR allows that boundary value. The validation now rejects
only element sizes greater than `ushort.MaxValue`.
- Updated NativeAOT compiler type validation:
- `>= ushort.MaxValue` → `> ushort.MaxValue`
- Added a focused InlineArray regression test:
- Verifies `[InlineArray(65535)]` can be used as an array element type.
- Covers NativeAOT compilation via `IlcCompile`.
```csharp
var array = new MaxSizedArrayElement[1];
[InlineArray(65535)]
struct MaxSizedArrayElement
{
private byte _first;
}
```
### Test methodology
- Built the NativeAOT compiler project.
- Built and ran the new regression test on CoreCLR.
- Built and ran the NativeAOT-compiled test binary.
### Additional context
This keeps NativeAOT behavior consistent with CoreCLR at the maximum
supported array element size boundary.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Description
NativeAOT rejected array element value types of exactly 65,535 bytes, while CoreCLR allows that boundary value. The validation now rejects only element sizes greater than
ushort.MaxValue.>= ushort.MaxValue→> ushort.MaxValue[InlineArray(65535)]can be used as an array element type.IlcCompile.Test methodology
Additional context
This keeps NativeAOT behavior consistent with CoreCLR at the maximum supported array element size boundary.