From 915a7ccbdb3af26e058d4b3b29b208f37be6b59c Mon Sep 17 00:00:00 2001 From: Uttam Bhadauriya Date: Tue, 3 Nov 2026 22:41:58 +0530 Subject: [PATCH] gh-159118: Use multithreaded COM initialization in _wmi (GH-159463) (cherry picked from commit 99799a9d3068e857cd025fcf320ac8863c99ff3e) Co-authored-by: Uttam Bhadauriya --- .../next/Windows/2026-10-15-18-45-00.gh-issue-159118.wmiMTA.rst | 1 + PC/_wmimodule.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Windows/2026-10-15-18-45-00.gh-issue-159118.wmiMTA.rst diff --git a/Misc/NEWS.d/next/Windows/2026-10-15-18-45-00.gh-issue-159118.wmiMTA.rst b/Misc/NEWS.d/next/Windows/2026-10-15-18-45-00.gh-issue-159118.wmiMTA.rst new file mode 100644 index 000000000000000..561a5005b759755 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-10-15-18-45-00.gh-issue-159118.wmiMTA.rst @@ -0,0 +1 @@ +Fix a crash (``RPC_NT_INTERNAL_ERROR``) and intermittent window class failures in :mod:`!_wmi` under high concurrency and load by initializing COM as multi-threaded (MTA) instead of apartment-threaded (STA). diff --git a/PC/_wmimodule.cpp b/PC/_wmimodule.cpp index b9a229b1398ec8d..a546313529fd1b1 100644 --- a/PC/_wmimodule.cpp +++ b/PC/_wmimodule.cpp @@ -67,7 +67,7 @@ _query_thread(LPVOID param) } if (SUCCEEDED(hr)) { - hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); } if (FAILED(hr)) {