Skip to content

Commit 9f2ff3f

Browse files
Fix assert for ARM shuffle thunk (#66642)
Handle case where gap exists at the beginning of the stack range. Fix #13241
1 parent 1fd8eee commit 9f2ff3f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/coreclr/vm/arm/stubs.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,9 @@ VOID StubLinkerCPU::EmitShuffleThunk(ShuffleEntry *pShuffleEntryArray)
15041504
DWORD dwSrcIndex = pEntry->srcofs & ShuffleEntry::OFSMASK;
15051505
if (dwSrcIndex != (dwLastSrcIndex + 1))
15061506
{
1507-
_ASSERTE(dwSrcIndex > dwLastSrcIndex);
1507+
// If the gap is at the very beginning, then dwLastSrcIndex is still -1, so we need to allow
1508+
// for that. Note that the calculation below handles this properly, due to DWORD wrapping.
1509+
_ASSERTE((dwLastSrcIndex == (DWORD)-1) || (dwSrcIndex > dwLastSrcIndex));
15081510

15091511
// add r4, #gap_size
15101512
ThumbEmitIncrement(ThumbReg(4), (dwSrcIndex - dwLastSrcIndex - 1) * 4);
@@ -1528,7 +1530,9 @@ VOID StubLinkerCPU::EmitShuffleThunk(ShuffleEntry *pShuffleEntryArray)
15281530
DWORD dwDstIndex = pEntry->dstofs & ShuffleEntry::OFSMASK;
15291531
if (dwDstIndex != (dwLastDstIndex + 1))
15301532
{
1531-
_ASSERTE(dwDstIndex > dwLastDstIndex);
1533+
// If the gap is at the very beginning, then dwLastDstIndex is still -1, so we need to allow
1534+
// for that. Note that the calculation below handles this properly, due to DWORD wrapping.
1535+
_ASSERTE((dwLastDstIndex == (DWORD)-1) || (dwDstIndex > dwLastDstIndex));
15321536

15331537
// add r5, #gap_size
15341538
ThumbEmitIncrement(ThumbReg(5), (dwDstIndex - dwLastDstIndex - 1) * 4);

0 commit comments

Comments
 (0)