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] non-zeroing stackalloc detects SP subtraction wrap with bvc (signed overflow), so a huge stackalloc silently succeeds instead of overflowing the stack #135524
On arm64, genLclHeap checks the wrap of sp - size for a non-zeroing stackalloc with the V flag (bvc) instead of the carry flag. For a huge size, SP is set to a wrapped, invalid address without any probing instead of raising a stack overflow.
The process dies with Stack overflow. (a ~2^51-byte stackalloc can't succeed; Test(1 << 18, 0), ~2^38 bytes, does report Stack overflow.).
Actual
Prints 2147483647: SP is set to a wrapped, invalid address and no probing happens.
Regression?
No. Reproduces on .NET 10.0.12 and main Release.
Notes
genLclHeap (codegenarm64.cpp) emits subs regCnt, sp, regCnt; bvc Loop; mov regCnt, #0. For SP < N < 2^63 the unsigned subtraction borrows but V=0, so the clamp to 0 is skipped, the probe loop exits at once (cmp x2, x1; blo done) and mov sp, wrappedValue runs.
It should test the carry flag (bhs/bcs) instead. Touching s[k] then faults near the wrapped SP.
Activity
dotnet-policy-service commentedon Oct 9, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: use the carry flag to detect SP wraparound in genLclHeap on ARM (#…