Repository navigation
Fix Linux crash loading recursive Nullable static-abstract value types - #130088
Conversation
|
Tagging subscribers to this area: @agocke |
…th recursive generics Co-authored-by: davidwrighton <[email protected]>
|
@copilot, returning false from |
…g false When ClassifyEightBytesWithManagedLayout is called recursively with pByValueClassCache=NULL, ByValueClassCacheLookup returns NULL for value-type fields. The subsequent GetSize(NULL) call resolves the field type via LookupApproxFieldTypeHandle (DontLoadTypes), which can fail to find a generic instantiation that was canonicalized during recursive layout loading (e.g. EntityIdValue<UserId> → EntityIdValue<__Canon>), causing a null TypeHandle assert in debug or SIGSEGV in release. Fix: when pByValueClassCache is NULL and the field is ELEMENT_TYPE_VALUETYPE, call GetApproxFieldTypeHandleThrowing() (LoadTypes + dropGenericArgumentLevel=TRUE) which always resolves to the canonical __Canon form and never returns null. Pre-resolve pFirstFieldValueTypeMT before the HasImpliedRepeatedFields call and thread it through all subsequent GetSize() invocations. Co-authored-by: davidwrighton <[email protected]>
Fixed in 2280e79. Instead of returning |
davidwrighton
left a comment
There was a problem hiding this comment.
@copilot, the fix to methodtable.cpp is correct. Do not change it. However, the test placement is wrong. Please fix.
Co-authored-by: davidwrighton <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/coreclr/vm/methodtable.cpp:2218
- The comment says
GetApproxFieldTypeHandleThrowing"always succeeds", but it can throw (e.g., type load failure / OOM). To avoid misleading future readers, please reword this to indicate that it avoids returning a null TypeHandle by loading (or throwing) rather than guaranteeing success.
// field MT. Otherwise look up the cache entry; when pByValueClassCache is NULL
// (recursive call) the exact generic instantiation may not be in the type loader hash
// yet, so fall back to GetApproxFieldTypeHandleThrowing which loads the canonical
// __Canon form and always succeeds.
Co-authored-by: davidwrighton <[email protected]>
AaronRobinsonMSFT
left a comment
There was a problem hiding this comment.
Is anything needed for native AOT or mono here?
…a helper - Extract ResolveValueTypeFieldMT to collapse three near-duplicate resolve-then-fallback blocks in System V struct classification. - Move the explanatory comment (including how GetApproxFieldTypeHandleThrowing implies dropGenericArgumentLevel=TRUE) onto the helper. - Use NULL and test the pointer before the field type, matching file style. - Remove the now-dead fieldIndexForCacheLookup variable and its reset. Co-authored-by: Copilot <[email protected]> Copilot-Session: dbf1f745-5a2e-46aa-86c1-a1f50eb42c63
No. This fix is specific to CoreCLR's runtime System V (Unix x64) struct classification in
I confirmed the repro from #127696 doesn't reproduce under either, so no changes are needed there. Note AI-generated (GitHub Copilot) on behalf of @davidwrighton. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/tests/Loader/classloader/regressions/LoaderClassloaderRegressions.csproj:9
- The PR description says the regression is wired into
Regression_o_2, but the changes actually add the new test to the Loader/classloader merged regressions project. Please either update the PR description, or also wire the test into the intended JIT regression project if that was the plan.
<ItemGroup>
<Compile Include="GitHub_127696/GitHub_127696.cs" />
<MergedWrapperProjectReference Include="*/**/*.??proj" />
</ItemGroup>
|
/ba-g infra issues |
dotnet#130088) This change addresses a Linux CoreCLR crash during prestub/JIT-triggered type loading of `Nullable<T>` when `T` is a recursively constrained value type using static abstract interface members. The failure came from System V struct classification assuming nested value-type metadata was always resolvable during approximate load. - **VM change** - Teach managed-layout System V struct classification to treat temporarily unresolved nested value-type field metadata as a conservative fallback instead of asserting. - Reuse small helpers to: - resolve value-type field handles when available - compute field sizes without forcing the existing assert path - Result: recursive/partially loaded cases fall back to non-register passing rather than crashing. - **Regression coverage** - Add a JIT regression covering the reported shape: - `Nullable<UserId>` - `UserId` as a `readonly record struct` - recursive generic interface constraint - `static abstract` interface members - Wire the test into `Regression_o_2`. - **Scenario covered** ```csharp class MyNullableUser { public UserId? UserId { get; set; } } public interface IEntityId<TSelf> : IEntityId where TSelf : IEntityId<TSelf> { EntityIdValue<TSelf> Value { get; } static abstract int MaxValue { get; } } public readonly record struct UserId(EntityIdValue<UserId> Value) : IEntityId<UserId>; ``` Fixes dotnet#127696 and dotnet#130661 --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: davidwrighton <[email protected]> Co-authored-by: David Wrighton <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: dbf1f745-5a2e-46aa-86c1-a1f50eb42c63
This change addresses a Linux CoreCLR crash during prestub/JIT-triggered type loading of
Nullable<T>whenTis a recursively constrained value type using static abstract interface members. The failure came from System V struct classification assuming nested value-type metadata was always resolvable during approximate load.VM change
Regression coverage
Nullable<UserId>UserIdas areadonly record structstatic abstractinterface membersRegression_o_2.Scenario covered
Fixes [JIT] SIGSEGV on Linux when loading
Nullable<T>whereTis areadonly record structwithstatic abstractinterface members #127696 and SIGSEGV in type loader when a struct wrapping a CRTP-constrained struct is loaded before its field type #130661