Skip to content

Handle DAC DefaultCOMImpl ref-counting fix (CLRDATA_REQUEST_REVISION 10)#1401

Merged
max-charlamb merged 2 commits intomicrosoft:mainfrom
max-charlamb:com-leak-fix
Mar 10, 2026
Merged

Handle DAC DefaultCOMImpl ref-counting fix (CLRDATA_REQUEST_REVISION 10)#1401
max-charlamb merged 2 commits intomicrosoft:mainfrom
max-charlamb:com-leak-fix

Conversation

@max-charlamb
Copy link
Copy Markdown
Contributor

The DAC's DefaultCOMImpl::Release() used post-decrement (mRef--) instead of pre-decrement (--mRef), leaking all DefaultCOMImpl-derived COM objects. ClrMD compensated with an extra Release() after wrapping enumerators. With the fix in dotnet/runtime#125231 (CLRDATA_REQUEST_REVISION bumped to 10), the extra Release() would prematurely free the object.

Changes:

  • DacRuntime: Accept DAC version 9 and 10, store version on SOSDac
  • SOSDac: Add DacVersion property and ReleaseLeakedDacRef() helper that only releases the leaked ref when DacVersion < 10

@max-charlamb max-charlamb requested a review from leculver March 6, 2026 17:54
leculver
leculver previously approved these changes Mar 6, 2026
Copy link
Copy Markdown
Contributor

@leculver leculver left a comment

Choose a reason for hiding this comment

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

Nitpick doesn't block merge, thanks!

The DAC's DefaultCOMImpl::Release() used post-decrement (mRef--)
instead of pre-decrement (--mRef), leaking all DefaultCOMImpl-derived
COM objects. ClrMD compensated with an extra Release() after wrapping
enumerators. With the fix in dotnet/runtime#125231
(CLRDATA_REQUEST_REVISION bumped to 10), the extra Release() would
prematurely free the object.

Changes:
- DacRuntime: Accept DAC version 9 and 10, store version on SOSDac
- SOSDac: Add DacVersion property and ReleaseLeakedDacRef() helper
  that only releases the leaked ref when DacVersion < 10

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
throw new InvalidDataException("This instance of CLR either has not been initialized or does not contain any data. This may indicate the dump was taken before the CLR was fully initialized, or the dump is corrupt or truncated. Failed to request DacVersion.");

if (version != 9)
if (version < 9)
Copy link
Copy Markdown
Member

@jkotas jkotas Mar 7, 2026

Choose a reason for hiding this comment

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

Should this also reject versions higher than 10? I do not think the future versions are expected to be compatible (as this change is demonstrating).

Future DAC versions may not be compatible, so reject unknown versions
rather than accepting all versions >= 9.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@max-charlamb max-charlamb requested review from jkotas and leculver March 9, 2026 19:18
@max-charlamb max-charlamb merged commit 470fa82 into microsoft:main Mar 10, 2026
8 checks passed
@max-charlamb max-charlamb deleted the com-leak-fix branch March 10, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants