stacktrace icon indicating copy to clipboard operation
stacktrace copied to clipboard

[Windows] Remove `::CoInitializeEx(0, COINIT_MULTITHREADED);`

Open AlexGuteniev opened this issue 3 years ago • 1 comments

https://github.com/boostorg/stacktrace/blob/75b7986f9799184ecd679d86273532cb54e6a0dc/include/boost/stacktrace/detail/frame_msvc.ipp#L60

CoInitializeEx is superfluous for DbgEng.h interfaces. These interfaces are COM-like, not completely COM compliant interfaces, and they don't use COM apartments.

It is now official - see https://github.com/MicrosoftDocs/windows-driver-docs-ddi/pull/1256#issuecomment-1031922715

The potential harm of ::CoInitializeEx(0, COINIT_MULTITHREADED); is that:

  • Client code won't be able to initialize COM in COINIT_APAREMENTTHREADED mode in the same scope
  • If client code would try to initialize in COINIT_APAREMENTTHREADED mode without checking, this may end up in unbalanced calls

AlexGuteniev avatar Feb 07 '22 21:02 AlexGuteniev

In the context of #24, probably the COM initializer class shouldn't be totally removed, as DIA SDK is real COM and needs this stuff. Just don't use that for DbgEng

AlexGuteniev avatar Feb 09 '22 13:02 AlexGuteniev

In the context of https://github.com/boostorg/stacktrace/issues/24, probably the COM initializer class shouldn't be totally removed, as DIA SDK is real COM and needs this stuff. Just don't use that for DbgEng

I'm not planning to support DIA any time soon, especially due to the it's COM usage.

apolukhin avatar Sep 01 '22 15:09 apolukhin