Skip to content

Commit a11d532

Browse files
thaystggithub-actions
authored andcommitted
Fixing get incomplete context information and assigning invalid information to the context later.
1 parent b41d940 commit a11d532

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/coreclr/debug/di/process.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12676,7 +12676,11 @@ Reaction CordbProcess::TriageExcep1stChanceAndInit(CordbUnmanagedThread * pUnman
1267612676

1267712677
DT_CONTEXT context;
1267812678

12679-
context.ContextFlags = DT_CONTEXT_FULL;
12679+
#ifdef TARGET_X86
12680+
tempContext.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
12681+
#else
12682+
tempContext.ContextFlags = DT_CONTEXT_FULL;
12683+
#endif
1268012684

1268112685
BOOL fSuccess = DbiGetThreadContext(pUnmanagedThread->m_handle, &context);
1268212686

src/coreclr/debug/di/rsthread.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3721,9 +3721,15 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
37213721
LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: hijackCtx started as:\n"));
37223722
LogContext(GetHijackCtx());
37233723

3724-
// Save the thread's full context.
3724+
// Save the thread's full context for all platforms except for x86 because we need the
3725+
// DT_CONTEXT_EXTENDED_REGISTERS to avoid getting incomplete information and corrupt the thread context
37253726
DT_CONTEXT context;
3727+
#ifdef TARGET_X86
3728+
context.ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;;
3729+
#else
37263730
context.ContextFlags = DT_CONTEXT_FULL;
3731+
#endif
3732+
37273733
BOOL succ = DbiGetThreadContext(m_handle, &context);
37283734
_ASSERTE(succ);
37293735
// for debugging when GetThreadContext fails
@@ -3733,7 +3739,12 @@ HRESULT CordbUnmanagedThread::SetupFirstChanceHijackForSync()
37333739
LOG((LF_CORDB, LL_ERROR, "CUT::SFCHFS: DbiGetThreadContext error=0x%x\n", error));
37343740
}
37353741

3742+
#ifdef TARGET_X86
3743+
GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL | DT_CONTEXT_EXTENDED_REGISTERS;
3744+
#else
37363745
GetHijackCtx()->ContextFlags = DT_CONTEXT_FULL;
3746+
#endif
3747+
37373748
CORDbgCopyThreadContext(GetHijackCtx(), &context);
37383749
LOG((LF_CORDB, LL_INFO10000, "CUT::SFCHFS: thread=0x%x Hijacking for sync. Original context is:\n", this));
37393750
LogContext(GetHijackCtx());

0 commit comments

Comments
 (0)