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

[dac] Make GetObjectStringData return the needed buffer element count instead of byte count #110540

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1571,12 +1571,18 @@ ClrDataAccess::GetObjectStringData(CLRDATA_ADDRESS obj, unsigned int count, _Ino
count = needed;

TADDR pszStr = TO_TADDR(obj)+offsetof(StringObject, m_FirstChar);
hr = m_pTarget->ReadVirtual(pszStr, (PBYTE)stringData, count * sizeof(WCHAR), &needed);
ULONG32 bytesRead;
hr = m_pTarget->ReadVirtual(pszStr, (PBYTE)stringData, count * sizeof(WCHAR), &bytesRead);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good as long as ReadVirtual fails on partial reads. I don't remember if it does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, seems like it does not - succeeds as long as any bytesRead > 0.

needed = bytesRead / sizeof(WCHAR);

if (SUCCEEDED(hr))
{
stringData[count - 1] = W('\0');
}
else
{
stringData[0] = W('\0');
}
}
else
{
Expand Down
Loading