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) [Tier0] ArgumentNullException.ThrowIfNull(r.Ref) on a null byref no longer throws NullReferenceException #135822
In Tier0 a struct box is a CORINFO_HELP_BOX(cls, addr) call; the "Case 1b" path in impThrowIfNull keeps only the evaluation of addr and drops the read through it that the helper would do, so a null byref is never dereferenced.
NullReferenceException (reading the null byref r.Ref must fault).
Actual
no exception
Tier0 only spills the byref to a "boxedAddr spilled" temp and never reads through it. With DOTNET_TieredCompilation=0 (FullOpts) it correctly prints NullReferenceException (cmp byte ptr [rcx], cl is kept).
main (Checked): no exception - regression on main ("Case 1b" is newer than the .NET 10 runtime tested).
Notes
Compiler::impThrowIfNull, "Case 1b" (value->IsHelperCall(CORINFO_HELP_BOX)): spills boxHelperAddrArg and returns gtNewNothingNode(), assuming the helper has no effect beyond computing its address argument.
The helper also reads addr to copy the struct, which can fault; Case 1 (GT_BOX) preserves this via gtTryRemoveBoxUpstreamEffects.
Fix: keep a null check/read of addr (e.g. GT_NULLCHECK) in Case 1b.
Activity
dotnet-policy-service commentedon Oct 14, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: preserve null checks when folding ThrowIfNull in Tier0 (dotnet#1…