microsoft / wil

Windows Implementation Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CoRegisterMallocSpy causes unit tests to fail periodically

jonwis opened this issue · comments

Discovered in #359, tests that use or validate helpers for CoRegisterMallocSpy cause downstream breaks for correct working code.

This tracks following one of the solutions proposed by @dunhor in #359 (comment)

There's a crash in the tests caused by a bug in COM that's caused by a combination of using IMallocSpy and not cleaning up C++/WinRT's CoIncrementMTAUsage. Raymond and I have chatted about this a bit offline (as it turns out, this is not the first test to fail because of it), and I've floated a few ideas:

  1. Simplest thing is to manually call CoInitialize as I've suggested above. This bypasses >?>C++/WinRT's logic & we don't hit the issue because we've properly cleaned up COM before process exit
  2. Another simple thing to do is to disable the test, but obviously not ideal
  3. Another idea I've floated is to tag the tests that use IMallocSpy specially and then perform two passes of test invocation: one that excludes the IMallocSpy-using tests and one that only runs those tests

I'm personally a fan of option 1: it's simple and effective. Option 3 would help us avoid these issues moving forward, however.

cc @oldnewthing as well