Skip to content

Commit 8d4f8b8

Browse files
authored
SPMI: Handle "successful error cases" in near differ on arm64 (#91783)
After #89654 SPMI replay will succeed instead of result in replay errors in expected error cases (such as BADCODE or EE exception). To support diffing such contexts, we record zero-sized assembly that the near differ uses. However, on arm64 there is some additional code that calls repCompileMethod to make some additional adjustments to the code blob, and in the "EE exception" cases we cannot replay this function, resulting in crash during asmdiff. This fixes the problem by only making the adjustments when we know there is any code. An alternative solution could be to avoid invoking the neardiffer at all in the succeeding error cases, but this seemed like an ok pragmatic solution. Fix #91257
1 parent 7082819 commit 8d4f8b8

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/coreclr/tools/superpmi/superpmi/neardiffer.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,28 +1247,29 @@ bool NearDiffer::compare(MethodContext* mc, CompileResult* cr1, CompileResult* c
12471247
// is a sum of their sizes. The following is to adjust their sizes and the roDataBlock_{1,2} pointers.
12481248
if (GetSpmiTargetArchitecture() == SPMI_TARGET_ARCHITECTURE_ARM64)
12491249
{
1250-
BYTE* nativeEntry_1;
1251-
ULONG nativeSizeOfCode_1;
1252-
CorJitResult jitResult_1;
1253-
1254-
BYTE* nativeEntry_2;
1255-
ULONG nativeSizeOfCode_2;
1256-
CorJitResult jitResult_2;
1257-
1258-
cr1->repCompileMethod(&nativeEntry_1, &nativeSizeOfCode_1, &jitResult_1);
1259-
cr2->repCompileMethod(&nativeEntry_2, &nativeSizeOfCode_2, &jitResult_2);
1260-
1261-
roDataSize_1 = hotCodeSize_1 - nativeSizeOfCode_1;
1262-
roDataSize_2 = hotCodeSize_2 - nativeSizeOfCode_2;
1263-
1264-
roDataBlock_1 = hotCodeBlock_1 + nativeSizeOfCode_1;
1265-
roDataBlock_2 = hotCodeBlock_2 + nativeSizeOfCode_2;
1266-
1267-
orig_roDataBlock_1 = (void*)((size_t)orig_hotCodeBlock_1 + nativeSizeOfCode_1);
1268-
orig_roDataBlock_2 = (void*)((size_t)orig_hotCodeBlock_2 + nativeSizeOfCode_2);
1250+
if (hotCodeSize_1 > 0)
1251+
{
1252+
BYTE* nativeEntry_1;
1253+
ULONG nativeSizeOfCode_1;
1254+
CorJitResult jitResult_1;
1255+
cr1->repCompileMethod(&nativeEntry_1, &nativeSizeOfCode_1, &jitResult_1);
1256+
roDataSize_1 = hotCodeSize_1 - nativeSizeOfCode_1;
1257+
roDataBlock_1 = hotCodeBlock_1 + nativeSizeOfCode_1;
1258+
orig_roDataBlock_1 = (void*)((size_t)orig_hotCodeBlock_1 + nativeSizeOfCode_1);
1259+
hotCodeSize_1 = nativeSizeOfCode_1;
1260+
}
12691261

1270-
hotCodeSize_1 = nativeSizeOfCode_1;
1271-
hotCodeSize_2 = nativeSizeOfCode_2;
1262+
if (hotCodeSize_2 > 0)
1263+
{
1264+
BYTE* nativeEntry_2;
1265+
ULONG nativeSizeOfCode_2;
1266+
CorJitResult jitResult_2;
1267+
cr2->repCompileMethod(&nativeEntry_2, &nativeSizeOfCode_2, &jitResult_2);
1268+
roDataSize_2 = hotCodeSize_2 - nativeSizeOfCode_2;
1269+
roDataBlock_2 = hotCodeBlock_2 + nativeSizeOfCode_2;
1270+
orig_roDataBlock_2 = (void*)((size_t)orig_hotCodeBlock_2 + nativeSizeOfCode_2);
1271+
hotCodeSize_2 = nativeSizeOfCode_2;
1272+
}
12721273
}
12731274

12741275
LogDebug("HCS1 %d CCS1 %d RDS1 %d xcpnt1 %d flag1 %08X, HCB %p CCB %p RDB %p ohcb %p occb %p odb %p", hotCodeSize_1,

0 commit comments

Comments
 (0)