Skip to content

Commit 09eea2a

Browse files
[debugger] Fix a step that becomes a go (#110484)
* Fixing step becomes a go * Trying to avoid step that becomes a go * Adding comments and more protections. * fixing comment * Checking if removing this comments, CI failures are gone. * Adding part of the changes to understand the failures on CI * Update src/coreclr/debug/ee/controller.cpp Co-authored-by: mikelle-rogers <[email protected]> * Fixing wrong fix. --------- Co-authored-by: mikelle-rogers <[email protected]>
1 parent 54e5b71 commit 09eea2a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/coreclr/debug/ee/controller.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -7585,7 +7585,15 @@ bool DebuggerStepper::TriggerSingleStep(Thread *thread, const BYTE *ip)
75857585
if (!g_pEEInterface->IsManagedNativeCode(ip))
75867586
{
75877587
LOG((LF_CORDB,LL_INFO10000, "DS::TSS: not in managed code, Returning false (case 0)!\n"));
7588-
DisableSingleStep();
7588+
// Sometimes we can get here with a callstack that is coming from an APC
7589+
// this will disable the single stepping and incorrectly resume an app that the user
7590+
// is stepping through.
7591+
#ifdef FEATURE_THREAD_ACTIVATION
7592+
if ((thread->m_State & Thread::TS_DebugWillSync) == 0)
7593+
#endif
7594+
{
7595+
DisableSingleStep();
7596+
}
75897597
return false;
75907598
}
75917599

src/coreclr/vm/threadsuspend.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -5732,8 +5732,9 @@ BOOL CheckActivationSafePoint(SIZE_T ip)
57325732
Thread *pThread = GetThreadNULLOk();
57335733

57345734
// The criteria for safe activation is to be running managed code.
5735-
// Also we are not interested in handling interruption if we are already in preemptive mode.
5736-
BOOL isActivationSafePoint = pThread != NULL &&
5735+
// Also we are not interested in handling interruption if we are already in preemptive mode nor if we are single stepping
5736+
BOOL isActivationSafePoint = pThread != NULL &&
5737+
(pThread->m_StateNC & Thread::TSNC_DebuggerIsStepping) == 0 &&
57375738
pThread->PreemptiveGCDisabled() &&
57385739
ExecutionManager::IsManagedCode(ip);
57395740

@@ -5918,7 +5919,12 @@ bool Thread::InjectActivation(ActivationReason reason)
59185919
{
59195920
return true;
59205921
}
5921-
5922+
// Avoid APC calls when the thread is in single step state to avoid any
5923+
// wrong resume because it's running a native code.
5924+
if ((m_StateNC & Thread::TSNC_DebuggerIsStepping) != 0)
5925+
{
5926+
return false;
5927+
}
59225928
#ifdef FEATURE_SPECIAL_USER_MODE_APC
59235929
_ASSERTE(UseSpecialUserModeApc());
59245930

0 commit comments

Comments
 (0)