Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debugger] Fix a step that becomes a go #110484

Merged
merged 9 commits into from
Dec 9, 2024
10 changes: 9 additions & 1 deletion src/coreclr/debug/ee/controller.cpp
Original file line number Diff line number Diff line change
@@ -7585,7 +7585,15 @@ bool DebuggerStepper::TriggerSingleStep(Thread *thread, const BYTE *ip)
if (!g_pEEInterface->IsManagedNativeCode(ip))
{
LOG((LF_CORDB,LL_INFO10000, "DS::TSS: not in managed code, Returning false (case 0)!\n"));
DisableSingleStep();
// Sometimes we can get here with a callstack that is coming from an APC
// this will disable the single stepping and wrongly resume an app that the user
// is stepping.
#ifdef FEATURE_THREAD_ACTIVATION
if ((thread->m_State & Thread::TS_DebugWillSync) == 0)
#endif
{
DisableSingleStep();
}
return false;
}

11 changes: 9 additions & 2 deletions src/coreclr/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
@@ -5733,7 +5733,9 @@ BOOL CheckActivationSafePoint(SIZE_T ip)

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

@@ -5918,7 +5920,12 @@ bool Thread::InjectActivation(ActivationReason reason)
{
return true;
}

// Avoid APC calls when the thread is in single step state to avoid any
// wrong resume because it's running a native code.
if ((m_StateNC & Thread::TSNC_DebuggerIsStepping) == 0)
{
return false;
}
#ifdef FEATURE_SPECIAL_USER_MODE_APC
_ASSERTE(UseSpecialUserModeApc());