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) MD-array Set elides the array covariance check when the element type is itself an array #133975
impArrayAccessIntrinsic treats a sealed reference element type as proof that an MD-array Set needs no covariance check. Array element types are sealed but covariant, so an inline Set can store an incompatible array reference into a covariant MD array.
The string reference actually points at a boxed int, so reading bad.Length reads the boxed payload as a string length.
Notes
impArrayAccessIntrinsic in src\coreclr\jit\importercalls.cpp uses CORINFO_FLG_FINAL on actualElemClsHnd to prove no runtime covariance check is needed.
Array types satisfy CORINFO_FLG_FINAL but are still covariant, so the inline expansion emits only a range check and write barrier instead of the covariance-checking Set/ARRADDR_ST path.
With DOTNET_JITMinOpts=1, the intrinsic is rejected and the real Set stub correctly throws ArrayTypeMismatchException.
Reproduces on released .NET 10.0.12 as well as main Checked.
changed the title [-]JIT (bug): MD-array `Set` elides the array covariance check when the element type is itself an array (type-safety hole)[/-][+]JIT (bug): MD-array `Set` elides the array covariance check when the element type is itself an array[/+]on Sep 15, 2026
changed the title [-]JIT (bug): MD-array `Set` elides the array covariance check when the element type is itself an array[/-][+]JIT: (bug) MD-array `Set` elides the array covariance check when the element type is itself an array[/+]on Sep 16, 2026
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.
[-]JIT (bug): MD-array `Set` elides the array covariance check when the element type is itself an array (type-safety hole)[/-][+]JIT (bug): MD-array `Set` elides the array covariance check when the element type is itself an array[/+][-]JIT (bug): MD-array `Set` elides the array covariance check when the element type is itself an array[/-][+]JIT: (bug) MD-array `Set` elides the array covariance check when the element type is itself an array[/+]JIT: don't elide the MD-array covariance check for covariant element …
EgorBo commentedon Sep 18, 2026
Affected SDK versions: