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
PGO: test failure in VolatileTest_op_mul on linux arm32 #57219
See CI Run -- this test has been failing on and off.
_Uarm_arm_exidx_step: ip and cfa unchanged; stopping here (ip=0xf4dae536)
_Uarm_arm_exidx_step: ip and cfa unchanged; stopping here (ip=0xf4dae536)
/root/helix/work/workitem/JIT/jit64/opt/cse/VolatileTest_op_mul/VolatileTest_op_mul.sh: line 348: 1535 Aborted (core dumped)
category:correctness
theme:profile-feedback
Activity
ghost added
untriagedNew issue has not been triaged by the area owner
This doesn't seem to be PGO specific, just that PGO seems more likely to trigger it somehow.
Running this slightly modified version on arm Linux, built release, with COMPlus_TC_QuickJitForLoops=1, and with additional CPU stress, on a checked runtime, I can get it to hang about 1 run out of every 3.
// Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the MIT license.usingSystem;usingSystem.Collections.Generic;usingSystem.Runtime.CompilerServices;usingSystem.Threading;usingSystem.Text;internalclassProgram{privatestaticintMain(string[]args){Console.WriteLine("this test is designed to hang if jit cse doesnt honor volatile");for(inti=0;i<10;i++){if(!TestCSE.Test())return1;}if(TestCSE.Test())return100;return1;}}publicclassTestCSE{privateconstintVAL1=0x404;privateconstintVAL2=0x03;privatestaticvolatilebools_timeUp=false;privatevolatileint_a;privatevolatileint_b;privatestaticint[]s_objs;staticTestCSE(){s_objs=newint[3];s_objs[0]=VAL1;s_objs[1]=VAL1;s_objs[2]=VAL2;}publicTestCSE(){_a=s_objs[0];_b=s_objs[1];}publicstaticboolEqual(intval1,intval2){if(val1==val2)returntrue;returnfalse;}publicstaticboolTestFailed(intresult,intexpected1,intexpected2,stringtname){if(result==expected1)returnfalse;if(result==expected2)returnfalse;Console.WriteLine("this failure may not repro everytime");Console.WriteLine("ERROR FAILED:"+tname+",got val1="+result+" expected value is, either "+expected1+" or "+expected2);thrownewException("check failed for "+tname);}[MethodImplAttribute(MethodImplOptions.NoInlining)]publicboolTestOp(){longi;Thread.Sleep(0);_a=VAL1;_b=VAL1;for(i=0;;i++){if(!Equal(_a*_b,_a*_b))break;if(!Equal(_a*_b,_a*_b))break;i++;}Console.WriteLine("Test 1 passed after "+i+" tries");_a=VAL1;_b=VAL1;for(i=0;;i++){if(!Equal(_a*_b,VAL1*VAL2))break;if(!Equal(_a*_b,VAL1*VAL2))break;}Console.WriteLine("Test 2 passed after "+i+" tries");boolpassed=false;_a=VAL1;_b=VAL1;for(i=0;;i++){intans1=_a*_b;intans2=_a*_b;if(TestFailed(ans1,VAL1*VAL1,VAL1*VAL2,"Test 3")||TestFailed(ans2,VAL1*VAL1,VAL1*VAL2,"Test 3")){passed=false;break;}if(ans1!=ans2){passed=true;break;}}Console.WriteLine("Test 3 "+(passed?"passed":"failed")+" after "+i+" tries");returnpassed;}privatevoidFlip(){for(uinti=0;!s_timeUp;i++){_a=s_objs[i%2];_b=s_objs[(i%2)+1];}}publicstaticboolTest(){s_timeUp=false;TestCSEo=newTestCSE();Threadt=newThread(newThreadStart(o.Flip));t.Start();boolans=o.TestOp();s_timeUp=true;t.Join();returnans;}}
In runtime we eventually hit a debug break in thread suspend on the tiered compilation worker thread indicating that thread suspension is taking too long:
* thread #7, name = '.NET Tiered Com', stop reason = signal SIGTRAP
* frame #0: 0xf7ac99b6 libcoreclr.so`DBG_DebugBreak + 2
frame #1: 0xf7a6c916 libcoreclr.so`::DebugBreak() at debug.cpp:406
frame #2: 0xf7865eaa libcoreclr.so`ThreadSuspend::SuspendRuntime(reason=<unavailable>) at threadsuspend.cpp:3569
frame #3: 0xf786847c libcoreclr.so`ThreadSuspend::SuspendEE(reason=SUSPEND_OTHER) at threadsuspend.cpp:5700
frame #4: 0xf761d9b8 libcoreclr.so`CallCountingManager::StopAndDeleteAllCallCountingStubs() at callcounting.cpp:961
frame #5: 0xf7721248 libcoreclr.so`TieredCompilationManager::DoBackgroundWork(this=0x0045e414, workDurationTicksRef=<unavailable>, minWorkDurationTicks=<unavailable>, maxWorkDurationTicks=50000000) at tieredcompilation.cpp:861
frame #6: 0xf7720270 libcoreclr.so`TieredCompilationManager::BackgroundWorkerStart(this=0x0045e414) at tieredcompilation.cpp:483
frame #7: 0xf77200f2 libcoreclr.so`TieredCompilationManager::BackgroundWorkerBootstrapper1((null)=<unavailable>) at tieredcompilation.cpp:431
frame #8: 0xf771b86c libcoreclr.so`ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) [inlined] ManagedThreadBase_DispatchInner(pCallState=<unavailable>) at threads.cpp:7312
frame #9: 0xf771b866 libcoreclr.so`ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) at threads.cpp:7356
frame #10: 0xf771b7b4 libcoreclr.so`ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) [inlined] ManagedThreadBase_DispatchOuter(this=<unavailable>, pParam=<unavailable>)::$_6::operator()(ManagedThreadBase_DispatchOuter(ManagedThreadCallState*)::TryArgs*) const::'lambda'(Param*)::operator()(Param*) const at threads.cpp:7514
frame #11: 0xf771b7ae libcoreclr.so`ManagedThreadBase_DispatchOuter(ManagedThreadCallState*) at threads.cpp:7516
frame #12: 0xf771b798 libcoreclr.so`ManagedThreadBase_DispatchOuter(pCallState=<unavailable>) at threads.cpp:7540
frame #13: 0xf771bdf4 libcoreclr.so`ManagedThreadBase::KickOff(void (*)(void*), void*) [inlined] ManagedThreadBase_FullTransition(pTarget=<unavailable>, args=<unavailable>, filterType=ManagedThread)(void*), void*, UnhandledExceptionLocation) at threads.cpp:7560
frame #14: 0xf771bdea libcoreclr.so`ManagedThreadBase::KickOff(pTarget=<unavailable>, args=<unavailable>)(void*), void*) at threads.cpp:7595
frame #15: 0xf7720046 libcoreclr.so`TieredCompilationManager::BackgroundWorkerBootstrapper0(args=0x0048eba8) at tieredcompilation.cpp:412
frame #16: 0xf7ac6434 libcoreclr.so`CorUnix::CPalThread::ThreadEntry(pvParam=0x0048e5d8) at thread.cpp:1862
frame #17: 0xf7f93614 libpthread.so.0`start_thread(arg=0xc3af7410) at pthread_create.c:463
frame #18: 0xf7d717fc libc.so.6 at clone.S:73
There are two threads in managed code, one in TestCSE.TestOp (tier0) and one in Test.Flip (tier0). TestCSE.Equal has just been jitted at Tier1 and has no GC safepoints:
Doesn't a method have to be fully-interruptible to support hijack-ing?
Since Equal is (incorrectly) marked partially interruptible, the hyjacking logic is not going to try to hijack when the PC is in that method. A partially interruptible method should always have a callsite in it.
I guess that for a method with straight-line code (no loops), we expect that the caller of the method will be partially interruptible, and that eventually the hi-jack retry logic will stop inside the caller method (and it will be partially interruptible)
Yes, it seems a bit odd to mark a method as partially interruptible without having any places it can actually be interrupted. Still not clear to me if the jit is at fault here. We do something similar for win x64 codegen, and I can't get the test to hang there.
What's supposed to happen is that we are supposed to hijack the thread running TestCSE.Equal, and at some point we should suspend during the following sequence of instructions.
If we did that, then we would hijack the return address. Unfortunately, from my understanding of the way instructions are handled by the various CPU's we support, I suspect the window for that happening is pretty small, as those are exceptionally cheap instructions. and the rest of the loop is heavy with a fair number of more expensive instructions such as CPU memory barriers, branches, and multiplies, etc.
Activity
AndyAyersMS commentedon Aug 11, 2021
This doesn't seem to be PGO specific, just that PGO seems more likely to trigger it somehow.
Running this slightly modified version on arm Linux, built release, with
COMPlus_TC_QuickJitForLoops=1, and with additional CPU stress, on a checked runtime, I can get it to hang about 1 run out of every 3.In runtime we eventually hit a debug break in thread suspend on the tiered compilation worker thread indicating that thread suspension is taking too long:
There are two threads in managed code, one in
TestCSE.TestOp(tier0) and one inTest.Flip(tier0).TestCSE.Equalhas just been jitted at Tier1 and has no GC safepoints:The jit reports
Equalis partially interruptible in the listing above, but doesn't define any interruptible ranges.There's a seemingly relevant discussion over in #35274 -- seems like this fits the bill, a long running loop with short-lived calls.
@janvorli any ideas on why we seemingly can't suspend threads via hijacks in this case?
cc @dotnet/jit-contrib
briansull commentedon Aug 11, 2021
Doesn't a method have to be fully-interruptible to support hijack-ing?
Since Equal is (incorrectly) marked partially interruptible, the hyjacking logic is not going to try to hijack when the PC is in that method. A partially interruptible method should always have a callsite in it.
briansull commentedon Aug 11, 2021
I guess that for a method with straight-line code (no loops), we expect that the caller of the method will be partially interruptible, and that eventually the hi-jack retry logic will stop inside the caller method (and it will be partially interruptible)
briansull commentedon Aug 11, 2021
Also this statement/comment doesn't give me very much confidence that this test is reliable:
Console.WriteLine("this test is designed to hang if jit cse doesnt honor volatile");briansull commentedon Aug 11, 2021
Also on (some?) Linix systems there used to be an issue with hi-jacking, such that we need to add GC-Polls to the method.
AndyAyersMS commentedon Aug 13, 2021
Yes, it seems a bit odd to mark a method as partially interruptible without having any places it can actually be interrupted. Still not clear to me if the jit is at fault here. We do something similar for win x64 codegen, and I can't get the test to hang there.
AndyAyersMS commentedon Aug 13, 2021
Looks like from the stress log LF_SYNC data that we never managed to stop in
Equals:all the stopping points are in the caller, and (apparenly) none of them at a safepoint in the caller.
JulieLeeMSFT commentedon Aug 13, 2021
CC VM team @mangod9, @davidwrighton, and @janvorli as an early headsup because @AndyAyersMS suspects this is either a runtime problem or a bad test.
JulieLeeMSFT commentedon Aug 16, 2021
VM team, please take a look.
davidwrighton commentedon Aug 16, 2021
What's supposed to happen is that we are supposed to hijack the thread running
TestCSE.Equal, and at some point we should suspend during the following sequence of instructions.If we did that, then we would hijack the return address. Unfortunately, from my understanding of the way instructions are handled by the various CPU's we support, I suspect the window for that happening is pretty small, as those are exceptionally cheap instructions. and the rest of the loop is heavy with a fair number of more expensive instructions such as CPU memory barriers, branches, and multiplies, etc.
AndyAyersMS commentedon Aug 17, 2021
David looked at the stress logs and doesn't see anything we can address for .NET 6. So moving this to future.
echesakov commentedon Aug 23, 2021
JIT/jit64/opt/cse/VolatileTest_op_xor also crashes on linux-arm with PGO - see console.log
AndyAyersMS commentedon Jun 19, 2024
Believe this should be fixed by #95565