Skip to content

Commit d51a70b

Browse files
tommcdonCopilotCopilot
authored
Fix x86 async frame generic type resolution in DBI (#126915)
CordbAsyncFrame::LoadGenericArgs was using SafeReadStruct<CORDB_ADDRESS> to read the generic arg token from the continuation object. CORDB_ADDRESS is ULONG64 (always 8 bytes), but on x86 targets the field is a 4-byte pointer. Reading 8 bytes pulled in adjacent memory, producing garbage pointer values that caused EnumerateTypeParameters to return E_INVALIDARG. Changed to SafeReadStruct<SIZE_T> which matches the target pointer size (4 bytes on x86, 8 bytes on x64), consistent with how CordbJITILFrame::LoadGenericArgs reads tokens via GetRegisterOrStackValue. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 39314d4 commit d51a70b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/coreclr/debug/di/rsthread.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11546,8 +11546,14 @@ void CordbAsyncFrame::LoadGenericArgs()
1154611546
{
1154711547
if (m_asyncVars[i].ilVarNum == genericArgIndex)
1154811548
{
11549-
11550-
HRESULT hr = GetProcess()->SafeReadStruct(m_continuationAddress + m_asyncVars[i].offset, &genericTypeParam);
11549+
// Read a target-pointer-sized value. CORDB_ADDRESS is always 8 bytes (ULONG64),
11550+
// but on x86 targets the generic arg field is only a 4-byte pointer. Using
11551+
// SIZE_T (which is pointer-sized for the DBI build, matching the target here)
11552+
// avoids reading adjacent memory. This mirrors how CordbJITILFrame::Init()
11553+
// reads the raw token via GetRegisterOrStackValue (which returns SIZE_T).
11554+
SIZE_T rawToken = 0;
11555+
HRESULT hr = GetProcess()->SafeReadStruct(m_continuationAddress + m_asyncVars[i].offset, &rawToken);
11556+
genericTypeParam = (CORDB_ADDRESS)rawToken;
1155111557
IfFailThrow(hr);
1155211558
break;
1155311559
}

0 commit comments

Comments
 (0)