[RyuJIT/ARM32] Regressions (segmentation fault) in RyuJIT/ARM32
Following tests failed with segmentation fault from recent upstream master in RyuJIT/ARM32 Checked, Release build. It doesn't fail in Debug.
FAILED - [ 0][ 15s]CoreMangLib/cti/system/array/ArraySort12/ArraySort12.sh
BEGIN EXECUTION
/mnt/albireo/mywork/device/rpi3/unittests/coreoverlays/coreoverlay.test20170928.Checked.debugging/corerun ArraySort12.exe
Beginning test case ArraySort12 at 17. 9. 28. 오후 4:58:46
Random seed: 20010415; set environment variable CORECLR_SEED to this value to repro
[Positive]
Beginning scenario: PosTest1: Sort a string array using customizes comparer
Beginning scenario: PosTest2: Sort an int32 array using comparer
./ArraySort12.sh: line 243: 7734 Segmentation fault (core dumped) $_DebuggerFullPath "$CORE_ROOT/corerun" $ExePath $CLRTestExecutionArguments
Expected: 100
Actual: 139
END EXECUTION - FAILED
Failed tests:
CoreMangLib/cti/system/array/ArraySort12
CoreMangLib/cti/system/array/ArraySort14
CoreMangLib/cti/system/collections/generic/dictionary/DictionaryICollectionAdd
CoreMangLib/cti/system/collections/generic/dictionary/DictionaryICollectionContains
CoreMangLib/cti/system/collections/generic/dictionary/DictionaryICollectionCopyTo
CoreMangLib/cti/system/collections/generic/dictionary/DictionaryICollectionCopyTo2
CoreMangLib/cti/system/collections/generic/idictionary/IDictionaryItem
GC/Scenarios/LeakWheel/leakwheel
I'm going to look into this.
It seems that this regression is introcuded from 74478f481290e3e5fb8ee3c2669b66a71ae0056c (#14090)
$ git bisect log
git bisect start
# good: [296aaf12b40ddd7478b6a14d6099f48b4b049438] Merge pull request dotnet/coreclr#14171 from wateret/ryu-arm-putarg-bitcast
git bisect good 296aaf12b40ddd7478b6a14d6099f48b4b049438
# bad: [dbdaf348f8a8ace5bd02a9074bef98c2ded95f3d] Merge pull request dotnet/coreclr#14207 from CarolEidt/Fix14028
git bisect bad dbdaf348f8a8ace5bd02a9074bef98c2ded95f3d
# good: [536cf25edfada76589a84e1620f93c39c15db167] Merge pull request dotnet/coreclr#14197 from rartemev/fixed_test_build_restore
git bisect good 536cf25edfada76589a84e1620f93c39c15db167
# good: [863625426be65b96f2a3c085fc049cfcd2f1a82a] Merge pull request dotnet/coreclr#14214 from stephentoub/quwi_preferlocal
git bisect good 863625426be65b96f2a3c085fc049cfcd2f1a82a
# good: [ccc5e17738a4b2f652059f31e8146513163dbee7] JIT: devirtualization support for EqualityComparer<T>.Default (#14125)
git bisect good ccc5e17738a4b2f652059f31e8146513163dbee7
# bad: [0d3c6848351a7a59a9bb586cdf3e064b09f87383] Merge pull request dotnet/coreclr#14090 from BredPet/interface_dispatch_cell
git bisect bad 0d3c6848351a7a59a9bb586cdf3e064b09f87383
# bad: [74478f481290e3e5fb8ee3c2669b66a71ae0056c] ARM32: fix interface dispatch cell address transfer
git bisect bad 74478f481290e3e5fb8ee3c2669b66a71ae0056c
# first bad commit: [74478f481290e3e5fb8ee3c2669b66a71ae0056c] ARM32: fix interface dispatch cell address transfer
@BredPet Do you have any clue ?
/cc: @dotnet/arm32-contrib
I don't know why, but in Release build CoreRT compiler always fails on ARM Tizen, there are some bugs in CoreRT and CoreCLR in Release case. We have not worked on their correction yet. It's strange that this happened on this patch. Perhaps something has worked correctly and there was another bug.
@BredPet Before the commit, all CoreCLR unit tests are passed in ryujit/arm32 in Release, Checked build in Ubuntu(armhf) and Tizen(armel). Maybe there are some remaining cases using REG_JUMP_THUNK_PARAM.
@BruceForstall @jkotas Do you have any idea ? I hope someone who knows inteface between JIT and runtime well look into this issue, because many of ryujit/arm32 developers including me will be out-of-office from tomorrow to Oct. 9th (about 10 days) due to long holidays.
I am not aware of any places that depends on it. If you could share some details about the crash (stacktrace, code that is crashing, etc.), I may have idea.
If necessary, it should be fine to make this change for CoreRT ABI only - ie add if (!IsTargetAbi(CORINFO_CORERT_ABI)).
I am not aware of any places that depends on it. If you could share some details about the crash (stacktrace, code that is crashing, etc.), I may have idea.
Here is a backtrace for CoreMangLib/cti/system/array/ArraySort12/ArraySort12.exe in Checked build with COMPlus_AltJit=*.
Thread 1 "corerun" received signal SIGSEGV, Segmentation fault.
VirtualCallStubManager::predictStubKind (this=<optimized out>, stubStartAddress=3221813471)
at /opt/code/github/hqueue/coreclr/src/vm/arm/virtualcallstubcpu.hpp:348
348 WORD firstWord = *((WORD*) pInstr);
(gdb) l
343 {
344 // If stubStartAddress is completely bogus, then this might AV,
345 // so we protect it with SEH. An AV here is OK.
346 AVInRuntimeImplOkayHolder AVOkay;
347
348 WORD firstWord = *((WORD*) pInstr);
349
350 //Assuming that RESOLVE_STUB_FIRST_WORD & DISPATCH_STUB_FIRST_WORD have same values
351 if (firstWord == DISPATCH_STUB_FIRST_WORD)
352 {
(gdb) bt
#0 VirtualCallStubManager::predictStubKind (this=<optimized out>, stubStartAddress=3221813471)
at /opt/code/github/hqueue/coreclr/src/vm/arm/virtualcallstubcpu.hpp:348
dotnet/coreclr#1 0x76595126 in VirtualCallStubManager::getStubKind (this=<optimized out>,
stubStartAddress=<optimized out>, usePredictStubKind=63711)
at /opt/code/github/hqueue/coreclr/src/vm/virtualcallstub.h:332
dotnet/coreclr#2 0x7660c62e in VirtualCallStubManager::FindStubManager (stubAddress=3221813471,
wbStubKind=0x7effe520, usePredictStubKind=1)
at /opt/code/github/hqueue/coreclr/src/vm/virtualcallstub.cpp:1002
dotnet/coreclr#3 0x7660f18a in VSD_ResolveWorker (pTransitionBlock=<optimized out>,
siteAddrForRegisterIndirect=<optimized out>, token=3081436854, flags=<optimized out>)
at /opt/code/github/hqueue/coreclr/src/vm/virtualcallstub.cpp:1600
dotnet/coreclr#4 0x76791512 in ResolveWorkerAsmStub ()
from /mnt/albireo/mywork/device/rpi3/unittests/coreoverlays/coreoverlay.test20170928.Checked.debugging/libcoreclr.so
dotnet/coreclr#5 0x6f53dba6 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) x/16i 0x6f53dba6-0x10
0x6f53db96: stmia r0!, {r2, r4}
0x6f53db98: mov r1, r12
0x6f53db9a: movw r4, dotnet/coreclr#100 ; 0x64
0x6f53db9e: movt r4, #30122 ; 0x75aa
0x6f53dba2: ldr r4, [r4, #0]
0x6f53dba4: blx r4
=> 0x6f53dba6: cmp r0, #0
0x6f53dba8: blt.n 0x6f53db44
0x6f53dbaa: ldr r3, [sp, dotnet/coreclr#4]
0x6f53dbac: ldr.w r12, [sp, dotnet/coreclr#20]
0x6f53dbb0: ldr.w lr, [sp, dotnet/coreclr#12]
0x6f53dbb4: add.w r1, r10, dotnet/coreclr#1
0x6f53dbb8: cmp r1, lr
0x6f53dbba: bcs.n 0x6f53dbe6
0x6f53dbbc: mov.w r2, r10, lsl dotnet/coreclr#2
0x6f53dbc0: add.w lr, r5, r2
If necessary, it should be fine to make this change for CoreRT ABI only - ie add if (!IsTargetAbi(CORINFO_CORERT_ABI)).
@jkotas Thank you for the suggestion. I will post a PR as a workaround if this is not fixed by today.
This is the problem:
0x6f53db9e: movt r4, #30122 ; 0x75aa
0x6f53dba2: ldr r4, [r4, #0]
0x6f53dba4: blx r4
This needs to be:
0x6f53db9e: movt r4, #30122 ; 0x75aa
0x6f53dba2: ldr rX, [r4, #0]
0x6f53dba4: blx rX
where rX != r4.
It sounds like that the register allocator does not know that there is important value in r4, and reuses r4 to store the call target into it.
@jkotas Thank you for the comment. Unfortunately after I've looked into code, I found out that it's related to setting argument of VSD call and it seems that we need changes in various phases. I couldn't make a correct fix yet by now.
Therefore I've posted a workaround PR.
/cc: @dotnet/arm32-contrib Please feel free to post a new fix, because many of ryujit/arm32 developers including me are AFK for more than a week.
Closing this, since the regression change has been reverted.