Commit Graph

3 Commits

Author SHA1 Message Date
b04fdc91c0 com_shim: nested CoUninitialize gives its host reference back; check TlsSetValue
Every nested co_initialize_ex() takes a host COM reference
(host_inits_owned), but co_uninitialize() gave them all back only at the
outermost CoUninitialize. A thread with an outer init that runs balanced
inner init/uninit pairs piled up one host reference per pair until the
outer balance (kevincommits' Finding 19 in #1608, item 1).

A nested CoUninitialize now gives back its own reference. The first
init's reference still stays until the guest balances, so host-first
teardown keeps working.

The first init also ignored TlsSetValue's result. When it fails, the
state is not tracked and no CoUninitialize would ever give the host
reference back, so the init now undoes it and fails with the error.

com_shim_test gains a case: 100 balanced nested pairs under an outer
init must leave exactly one host reference. It fails on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 19:36:14 -06:00
464bb23d9f com_shim: retain host apartment reference when absorbing RPC_E_CHANGED_MODE 2026-11-24 04:43:36 +07:00
ced87bf258 runtime/shims: shim api-ms-win-core-com-l1-1-0..3 lifecycle and helpers
Refs: https://github.com/ItsNotRexed/Leonida/issues/9065#issuecomment-7114294575
2026-11-24 04:21:05 +07:00