Bug 1965216: Fail gracefully for calls to LazyInstantiator::get_accChild on the wrong thread. r=morgan

This shouldn't happen, but the COM runtime seems to do this sometimes.
I can't reproduce it and I haven't been able to fathom what causes it.
I suspect a Windows bug or a bug in some third party software.
This leads to trying to check the UIA pref from the wrong thread, which is not allowd and causes a crash.

Differential Revision: https://phabricator.services.mozilla.com/D248558
This commit is contained in:
James Teh
2025-05-12 23:23:58 +00:00
committed by jteh@mozilla.com
parent 1276a883d6
commit 77343be3df

View File

@@ -590,6 +590,13 @@ LazyInstantiator::get_accChild(VARIANT varChild, IDispatch** ppdispChild) {
return S_OK; return S_OK;
} }
if (NS_WARN_IF(!NS_IsMainThread())) {
// Bug 1965216: The COM runtime occasionally calls this method on the wrong
// thread, violating COM rules. We can't reproduce this and don't understand
// what causes it.
return RPC_E_WRONG_THREAD;
}
RESOLVE_ROOT; RESOLVE_ROOT;
return mWeakAccessible->get_accChild(varChild, ppdispChild); return mWeakAccessible->get_accChild(varChild, ppdispChild);
} }