Skip to content

Commit 0f05719

Browse files
authored
Adjust IP after an AV during an STEP with FEATURE_EMULATE_SINGLESTEP enabled (#105633)
Fix step in a line that will throw an AV
1 parent 91154ba commit 0f05719

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/coreclr/debug/ee/controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3232,7 +3232,7 @@ void DebuggerController::UnapplyTraceFlag(Thread *thread)
32323232
// so there should be nothing to do. However, we still assert b/c we want to know how
32333233
// we'd actually hit this.
32343234
// @todo - is there a path if TriggerUnwind() calls DisableAll(). But why would
3235-
CONSISTENCY_CHECK_MSGF(false, ("How did we get here?. thread=%p\n", thread));
3235+
//CONSISTENCY_CHECK_MSGF(false, ("How did we get here?. thread=%p\n", thread)); it can be caused in a scenario where we are stepping and an AV is thrown
32363236
LOG((LF_CORDB,LL_INFO1000, "DC::UnapplyTraceFlag couldn't get context.\n"));
32373237
return;
32383238
}

src/coreclr/vm/exceptionhandling.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5426,6 +5426,17 @@ BOOL IsSafeToCallExecutionManager()
54265426

54275427
BOOL IsSafeToHandleHardwareException(PCONTEXT contextRecord, PEXCEPTION_RECORD exceptionRecord)
54285428
{
5429+
#ifdef FEATURE_EMULATE_SINGLESTEP
5430+
Thread *pThread = GetThreadNULLOk();
5431+
if (pThread && pThread->IsSingleStepEnabled() &&
5432+
exceptionRecord->ExceptionCode != STATUS_BREAKPOINT &&
5433+
exceptionRecord->ExceptionCode != STATUS_SINGLE_STEP &&
5434+
exceptionRecord->ExceptionCode != STATUS_STACK_OVERFLOW)
5435+
{
5436+
pThread->HandleSingleStep(contextRecord, exceptionRecord->ExceptionCode);
5437+
}
5438+
#endif
5439+
54295440
PCODE controlPc = GetIP(contextRecord);
54305441

54315442
if (IsIPInWriteBarrierCodeCopy(controlPc))

0 commit comments

Comments
 (0)