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
JIT: (bug) [ARM64] genPutArgStk gives both LDP destination registers the first field's GC type (bogus/missing GC roots) #134066
In CodeGen::genPutArgStk (codegenarmarch.cpp), the 16-byte ldp from an address expression passes emitTypeSize(type0) as the second register's GC attribute (attrReg2):
emit->emitIns_R_R_R_I(INS_ldp, emitTypeSize(type0), loReg, hiReg, addrReg, structOffset,
INS_OPTS_NONE, emitTypeSize(type0)); // <- should be emitTypeSize(type1)
The adjacent local-source ldp and the following stp both correctly use emitTypeSize(type1).
As a result, in a fully interruptible method, the second register is described with the first field's
GC-ness: a non-GC half is reported as a live GC reference (bogus root), or a reference half goes
unreported (missing root).
Repro
usingSystem;usingSystem.Runtime.CompilerServices;publicstructS{publiclongA;publicobjectB;}publicclassC{publicSS;}publicclassProgram{staticints_x;[MethodImpl(MethodImplOptions.NoInlining)]staticvoidConsume(longa,longb,longc,longd,longe,longf,longg,longh,Ss){if(s.A!=42||(string)s.B!="hello")thrownewException("bad");}[MethodImpl(MethodImplOptions.NoInlining|MethodImplOptions.AggressiveOptimization)]staticvoidTest(Cc){while(s_x!=0){s_x--;}// call-free loop => method is fully interruptibleConsume(1,2,3,4,5,6,7,8,c.S);}publicstaticintMain(){Cc=newC();c.S.A=42;c.S.B="hello";for(inti=0;i<1000;i++)Test(c);Console.WriteLine("done");return100;}}
Run on linux-arm64: DOTNET_TieredCompilation=0 DOTNET_GCStress=0x4 corerun repro.dll
Expected
done
Actual
crash
Notes
DOTNET_JitDisasm=Test DOTNET_JitDisasmWithGC=1 shows the defect directly: ldp x1, x2, [x0] followed by ; gcrRegs +[x1-x2] — x2 holds S.A (the long, value 42) but is reported live-GC until mov x2, #3.
Controls under identical settings all pass, isolating the attrReg2 argument: struct S { object B1; object B2; } (both halves GC), passing the struct from a local instead of c.S
(takes the correct emitIns_R_R_S_S path), and setting A = 0 (bogus root looks null).
DOTNET_JitFullyInt=1 without the loop reproduces identically.
Fix: pass emitTypeSize(type1) as the final argument.
Activity
dotnet-policy-service commentedon Sep 16, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: use the second field's GC type for the ldp hi register in genPut… (