Skip to content

Revert "Fix COM ref counting in SOSMethodEnum simulator and bump SOS_BREAKING_CHANGE_VERSION"#5748

Merged
max-charlamb merged 1 commit intomainfrom
revert-5746-com-ref-counting-fix
Mar 6, 2026
Merged

Revert "Fix COM ref counting in SOSMethodEnum simulator and bump SOS_BREAKING_CHANGE_VERSION"#5748
max-charlamb merged 1 commit intomainfrom
revert-5746-com-ref-counting-fix

Conversation

@max-charlamb
Copy link
Member

Reverts #5746

@max-charlamb max-charlamb requested a review from a team as a code owner March 6, 2026 15:55
Copilot AI review requested due to automatic review settings March 6, 2026 15:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reverts #5746 by restoring the previous SOS breaking-change version and undoing changes related to COM reference counting around the ISOSMethodEnum simulator/enumerator path.

Changes:

  • Revert SOS_BREAKING_CHANGE_VERSION from 6 back to 5 in the SOS IDL and prebuilt header.
  • Revert SOSMethodEnum simulator initialization/refcounting and how GetMethodTableSlotEnumerator returns the enumerator.
  • Update DumpMT to use a raw ISOSMethodEnum* instead of ToRelease<ISOSMethodEnum>.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/shared/pal/prebuilt/inc/sospriv.h Reverts the SOS breaking-change version macro to 5.
src/shared/inc/sospriv.idl Reverts the IDL-defined SOS breaking-change version macro to 5.
src/SOS/Strike/util.cpp Reverts simulator enumerator creation/hand-off logic for method table slot enumeration.
src/SOS/Strike/strike.cpp Reverts DumpMT enumerator handling from RAII to a raw COM pointer.
Comments suppressed due to low confidence (1)

src/SOS/Strike/strike.cpp:1326

  • pMethodEnumerator was changed from ToRelease<ISOSMethodEnum> to a raw ISOSMethodEnum*, but the code never calls Release() after the enumeration completes. This leaks the COM reference (and for the simulator case, leaks the heap allocation). Please restore RAII (e.g., ToRelease/ReleaseHolder) or add a guaranteed Release() on all paths after the loop.
        ISOSMethodEnum *pMethodEnumerator;
        if (SUCCEEDED(g_sos15->GetMethodTableSlotEnumerator(dwStartAddr, &pMethodEnumerator)))
        {
            SOSMethodData entry;
            unsigned int fetched;
            while (SUCCEEDED(pMethodEnumerator->Next(1, &entry, &fetched)) && fetched != 0)
            {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 3771 to 3782
SOSMethodEnum *simulator = new(std::nothrow) SOSMethodEnum(mt);
*enumerator = simulator;
if (simulator == NULL)
{
return E_OUTOFMEMORY;
}
HRESULT hr = simulator->Reset();

if (SUCCEEDED(hr))
hr = simulator->QueryInterface(__uuidof(ISOSMethodEnum), (void**)enumerator);

if (FAILED(hr))
delete simulator;

{
simulator->Release();
}
return hr;
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

GetMethodTableSlotEnumerator assigns *enumerator before validating the out-parameter and before knowing whether initialization succeeds. If Reset() fails, the code releases (and may delete) simulator but leaves *enumerator pointing at freed memory, and it will also AV if enumerator is null. Please validate enumerator (return E_POINTER), set *enumerator = nullptr on entry, and only publish the pointer on success (or explicitly null it after releasing on failure).

Copilot uses AI. Check for mistakes.
@max-charlamb max-charlamb merged commit 28637ec into main Mar 6, 2026
12 of 22 checks passed
@max-charlamb max-charlamb deleted the revert-5746-com-ref-counting-fix branch March 6, 2026 16:17
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