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) Vector128.WithElement range-checks a re-read of the index local (spurious AOORE / out-of-bounds stack write) #134893
The range check in WithElement re-reads the index local after the value argument modified it, while the store uses the original index. This produces a spurious ArgumentOutOfRangeException or an unchecked out-of-bounds stack write.
Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
The inverse case (idx = 6, Interlocked.Exchange(ref idx, 0)) passes the range check and writes past the 16-byte SIMD stack temp, causing an AccessViolation.
Regression?
Yes, regression in main (after 11.0-rc2). .NET 8.0, 9.0, 10.0 and 11.0-rc2 are correct.
Notes
Introduced by #133776. gtNewSimdWithElementNode uses fgMakeMultiUse(&op2), which clones the address-exposed index local instead of spilling it to a temp. As a result, the range check sees the value after op3 (the xchg) modified it.
The same pattern exists in gtNewSimdShuffleVariableNode (AVX2 non-VBMI path for variable Vector256<byte>.Shuffle, regression since .NET 10): op1 is cloned via fgMakeMultiUse and the Permute2x128 copy re-reads it after op2 ran. E.g. with S { [FieldOffset(0)] Vector256<byte> V; [FieldOffset(16)] long L; }, Vector256.Shuffle(s.V, Vector256.Create((byte)Interlocked.Exchange(ref s.L, -1))) returns <255 (x16), 16 (x16)> instead of all 16 under DOTNET_EnableAVX512=0.
Activity
dotnet-policy-service commentedon Sep 29, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
EgorBo commentedon Sep 30, 2026
cc @tannergooding
JIT: preserve SIMD operands across side effects (dotnet#137860)