Skip to content

Commit 897a631

Browse files
GregThochromeos-ci-prod
authored andcommitted
[windows] Include the return value of CoInitializeEx in crashes
WorkerThreadCOMDelegate fails to inititialize the thread as a COM single-threaded apartment from time to time. Many of these are due to OOM or ATOM exhaustion, and are handled by Chrome's `OnResourceExhausted` handler, but some are not. Include the return value from CoInitializeEx in a crash key in this case so that we can try to gain a bit more understanding of what is actually happening here. Bug: 40074523 Change-Id: Ie9b305ed7227cd9c54f76d4e79f9f38ca4a88dc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5970334 Auto-Submit: Greg Thompson <grt@chromium.org> Commit-Queue: Gabriel Charette <gab@chromium.org> Reviewed-by: Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/main@{#1374581} CrOS-Libchrome-Original-Commit: 26198b17db908c6b201889e5b5cfd5537edbd575
1 parent 8297dda commit 897a631

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

base/task/thread_pool/pooled_single_thread_task_runner_manager.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#if BUILDFLAG(IS_WIN)
4242
#include <windows.h>
4343

44+
#include "base/debug/crash_logging.h"
4445
#include "base/win/scoped_com_initializer.h"
4546
#endif // BUILDFLAG(IS_WIN)
4647

@@ -323,8 +324,20 @@ class WorkerThreadCOMDelegate : public WorkerThreadDelegate {
323324

324325
scoped_com_initializer_ = std::make_unique<win::ScopedCOMInitializer>();
325326

326-
// CHECK to make sure this COM thread is initialized correctly in an STA.
327-
CHECK(scoped_com_initializer_->Succeeded());
327+
// Make sure this COM thread is initialized correctly in an STA. The thread
328+
// would be in the default MTA state upon failure, which would mean any
329+
// other MTA thread could service calls invoked by COM on objects living in
330+
// this apartment.
331+
if (!scoped_com_initializer_->Succeeded()) {
332+
// Collect the reason when CoInitializeEx fails. Classic OOM (or ATOM
333+
// exhaustion) should lead to process death in ScopedCOMInitializer, but
334+
// other failures will leak out. Collect the failure codes in an effort to
335+
// understand whether or not these failures are actionable; see
336+
// https://crbug.com/40074523.
337+
SCOPED_CRASH_KEY_NUMBER("WorkerThreadCOMDelegate", "hr",
338+
scoped_com_initializer_->hr());
339+
NOTREACHED();
340+
}
328341
}
329342

330343
RegisteredTaskSource GetWork(WorkerThread* worker) override {

0 commit comments

Comments
 (0)