Skip to content

Conversation

@JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Dec 5, 2025

Fixes #5869 and #5870 in the current code and will be backported to 1.12

Change

Adds a test host that leverages the in-proc COM module (as built locally) to validate various lifetime management scenarios. It has numerous options for controlling the scenarios, as well as an extensible model for adding different tests in the future.

It was able to hit the faults described in the linked issues, and the fixes are included:

  • Move the ServerShutdownSynchronization to integrate with the signal monitoring directly, rather than registering as an object. This also means that there is no need to unregister, preventing the construction of a TerminationSignalHandler.
  • Remove the call that terminates COM objects from the DLL_PROCESS_DETACH handler. If the caller is using the module properly via COM, the DllCanUnloadNow calls should take care of things. If the process is exiting without that call, leaking objects will be fine (the caller didn't uninitialize COM, so it is doubtful they care about a clean exit).

Additionally, these changes were made to support additional scenarios:

  • Add the WinRT type names to the manifest file so that WinRT activation can work.
  • Fix the activation factories to be counted objects for the module.
  • Add a setting that allows the caller to prevent DllCanUnloadNow from checking the object state, always returning that it cannot unload now. This can be used to prevent the module from being unloaded (and any active static objects alive) even if no external objects are active.

Validation

The test host is run with various parameters as part of the E2E tests.
The linked issues are represented within the set of tests, as are several other scenarios.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner December 5, 2025 20:44
});
}

private void RunInprocTestbed(TestbedParameters parameters, int timeout = 300000)
Copy link
Member

Choose a reason for hiding this comment

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

Might be nice to have default timeout constant defined, though it looks like this is the only place it is referenced. This 5m seems like a good number since we've seen other tests hit 2m randomly.

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.

Access violation during process exit due to ComStaticStorageStatics

2 participants