You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crossgen: (bug) GC hole when an [InlineArray] is overlapped by a ref field at offset 0 (elements 1..N-1 lose their GC slots) #137842
CorInfoImpl.getClassGClayout reports an incomplete GC layout for an explicit-layout struct in which an object field overlaps element 0 of an [InlineArray] field. Only element 0 is reported as a GC slot, so R2R and NativeAOT code do not report elements 1..N-1 to the GC. JIT-only execution is correct.
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Program.Test(Int32 i)
at Program.Main()
The GC info for Test has only [rsp+0x28] (o / arr[0]) as a GC slot, but the code loads x.arr[1] from gword ptr [rsp+0x30]. ILC produces the same incomplete GC info.
Regression?
The bug is reported to also reproduce with .NET 10.0.15 PublishReadyToRun; this was not re-verified. It reproduces on main.
Notes
In GatherClassGCLayout, MarkGcField returns 0 when a slot is already marked with the same GC type. Because o marks slot 0 first, walking Arr gives result == 0, and the replication loop for elements 1..N-1 is skipped. Replication should depend on the element's GC layout (e.g. ContainsGCPointers), not on the number of newly marked slots.
Activity
dotnet-policy-service commentedon Nov 19, 2026
Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.