-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[cDAC] Add diagnostic logging to GetMethodTableName assertion #127399
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2995,6 +2995,13 @@ int ISOSDacInterface.GetMethodTableName(ClrDataAddress mt, uint count, char* mtN | |||||||
| Debug.ValidateHResult(hr, hrLocal); | ||||||||
| if (hr == HResults.S_OK) | ||||||||
| { | ||||||||
| if (pNeeded != null && *pNeeded != neededLocal) | ||||||||
| { | ||||||||
| string cdacStr = mtName is not null && count > 0 ? new string(mtName, 0, (int)System.Math.Min(*pNeeded, count) - 1) : "<null>"; | ||||||||
| string dacStr = neededLocal > 0 ? new string(mtNameLocal, 0, (int)neededLocal - 1) : "<empty>"; | ||||||||
|
||||||||
| string dacStr = neededLocal > 0 ? new string(mtNameLocal, 0, (int)neededLocal - 1) : "<empty>"; | |
| uint dacCount = System.Math.Min(neededLocal, count); | |
| string dacStr = dacCount > 0 ? new string(mtNameLocal, 0, (int)dacCount - 1) : "<empty>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidateOutputStringBuffercan throw while trying to build the diagnosticdacStrwhendacNeededis greater than the provideddacBufferlength (oftencount). In the mismatch case,dacNeededis exactly the scenario where the caller’s buffer may be too small, sonew string(dacBuffer, 0, (int)dacNeeded - 1)risksArgumentOutOfRangeExceptionand defeats the purpose of soft-fail diagnostics. Clamp the length to the available buffer size (e.g.,Math.Min(dacNeeded, (uint)dacBuffer.Length)/Math.Min(dacNeeded, count)) before constructing the string.