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) can pass an implicit-byref parameter as a struct return buffer, violating the retbuf stack invariant #133961
For non-async struct-returning calls, the importer can allow the address of an implicit-byref parameter to be used as the hidden return buffer. Morph then turns that local address into the incoming byref, so the callee may store GC references through a caller-supplied byref while assuming the retbuf points to stack memory.
The simple JIT-to-JIT repro prints hello, so the missed-barrier risk is latent unless the implicit byref points at GC heap memory.
Notes
The async path in impIsLegalRetBuf already rejects GT_LCL_ADDR of an implicit-byref local, but the non-async path relies on fgAddrCouldBeHeap, which returns false for GT_LCL_ADDR.
The implicit-byref rejection should apply to non-async retbufs too, or fgAddrCouldBeHeap should treat these local addresses as potentially heap-backed.
@jkotas so probably we should re-open #133304 to fix that? (I closed it only because I was not able to detect perf improvements from that, but apparently we can simplify the ABI if that place is the only one that might put a gc pointer there).
I cannot quite tell if that other path also gets used for the implicit byref cases. This place looks to be the only one that actually checks the ABI and fNeedBoxOrUnbox seems to be about actual byref typed parameters that are ok to point to heap.
@jkotas so probably we should re-open #133304 to fix that?
Yes, I like that change just for the cleaner contract alone. A few potential perf improvements are a cream on top - if we are not able to detect any, that's fine.
Activity
dotnet-policy-service commentedon Sep 15, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
jakobbotsch commentedon Sep 15, 2026
Implicit byrefs never point to heap today, #82166
EgorBo commentedon Sep 15, 2026
@jakobbotsch are you sure, the ABI doc disagrees: https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/clr-abi.md#amd64-only-by-value-value-types
EgorBo commentedon Sep 15, 2026
#133304 - my pr tried to fix that, apparently, the debugger part could still point it to the heap.
EgorBo commentedon Sep 15, 2026
https://github.com/dotnet/runtime/blob/main/src/coreclr/debug/ee/funceval.cpp#L1081-L1134
GetFuncEvalArgValueunboxes usingo1->GetData()and, when larger than anARG_SLOT, puts that heap pointer directly into the argument slotEgorBo commentedon Sep 15, 2026
@jkotas so probably we should re-open #133304 to fix that? (I closed it only because I was not able to detect perf improvements from that, but apparently we can simplify the ABI if that place is the only one that might put a gc pointer there).
jakobbotsch commentedon Sep 15, 2026
That same method has implicit byref handling here that looks to put it
on stackin private memory:runtime/src/coreclr/debug/ee/funceval.cpp
Lines 911 to 935 in 6905a9f
I cannot quite tell if that other path also gets used for the implicit byref cases. This place looks to be the only one that actually checks the ABI and
fNeedBoxOrUnboxseems to be about actualbyreftyped parameters that are ok to point to heap.Yes, it disagrees -- #82166 also points out that it should be updated.
jkotas commentedon Sep 15, 2026
Yes, I like that change just for the cleaner contract alone. A few potential perf improvements are a cream on top - if we are not able to detect any, that's fine.
Implicit byref arguments are never on the GC heap (#133304)