[PATCH] combase: Check all apartment types when looking for an apartment belonging to a thread.

Dmitry Timoshkov dmitry at baikal.ru
Tue Jul 20 13:14:44 CDT 2021


Hi Huw,

thanks for the review.

Huw Davies <huw at codeweavers.com> wrote:

> This doesn't look right.  At the very least, this won't work if the
> MTA isn't found, as it will return in the if block above.  More
> fundamentally though, what's actually going on here?  If the thread
> has joined an apartment-threaded apartment, then I'd expect that
> should be the one that's used.  Some tests would help here.

This happens during the client application connecting to a server object
residing in a separate process, that's a bit diffucult to replicate in a
test. Manifestation of the problem on the client side is
0020:0024:err:ole:ifproxy_get_public_ref IRemUnknown_RemAddRef returned with 0x00000001, hrref = 0x80010114
This is a subsequence that on the server side we see
0198:019c:err:ole:get_stub_manager_from_ipid not found for ipid {00000001-019c-0198-b129-50e64a2d6135}

Here is a relevant part of the log (with some additional info added):

server:
0188:018c:trace:ole:stub_manager_new_ifstub m 041E9C38: ifstub 041E9D98 created with ipid {00000001-018c-0188-8366-ab230df0e7d9}
client:
0020:0024:trace:ole:proxy_manager_create_ifproxy ifproxy 293FF3F8 created for IPID {00000001-018c-0188-8366-ab230df0e7d9}, interface {6d5140c1-7436-11ce-8034-00aa006009fa} with 0 public refs

and later when the client calls the server, the server side couldn't find
a proper apartment:
0188:0198:trace:ole:dispatch_rpc ipid = {ffffffff-ffff-ffff-8c01-000088010000}, iMethod = 4
0188:0198:trace:ole:apartment_addref 1880000018c: before = 1
0188:0198:trace:ole:apartment_findfromoxid 1880000018c => 002B8BF8 (apartment-threaded)
0188:0198:trace:ole:ipid_to_ifstub ipid {ffffffff-ffff-ffff-8c01-000088010000} (tid 0000ffff) => stub_apt 002B8BF8
0188:0198:trace:ole:get_stub_manager_from_ipid 002B8BF8,{ffffffff-ffff-ffff-8c01-000088010000}
0188:0198:trace:ole:stub_manager_ipid_to_ifstub m 041E9C38: looking for ipid {ffffffff-ffff-ffff-8c01-000088010000}
0188:0198:trace:ole:stub_manager_ipid_to_ifstub m 041E9C38: ifstub 041E9D98, ifstub->ipid {00000001-018c-0188-8366-ab230df0e7d9}
0188:0198:trace:ole:stub_manager_ipid_to_ifstub m 041E9C38: ipid: {ffffffff-ffff-ffff-8c01-000088010000} => 00000000
0188:0198:trace:ole:stub_manager_ipid_to_ifstub m 041E8AA8: looking for ipid {ffffffff-ffff-ffff-8c01-000088010000}
0188:0198:trace:ole:stub_manager_ipid_to_ifstub m 041E8AA8: ifstub 041E8B48, ifstub->ipid {ffffffff-ffff-ffff-8c01-000088010000}
0188:0198:trace:ole:stub_manager_ipid_to_ifstub m 041E8AA8: ipid: {ffffffff-ffff-ffff-8c01-000088010000} => 041E8B48
0188:0198:trace:ole:stub_manager_int_addref before 1
0188:0198:trace:ole:get_stub_manager_from_ipid found 041E8AA8 for ipid {ffffffff-ffff-ffff-8c01-000088010000}
0188:0198:trace:ole:ipid_to_ifstub stub_apt 002B8BF8, ipid {ffffffff-ffff-ffff-8c01-000088010000} (tid 0000ffff) => stubmgr_ret 041E8AA8
0188:0198:trace:ole:CStdStubBuffer_AddRef (041E8B28)->AddRef()
0188:0198:trace:ole:dispatch_rpc Calling apartment thread 0x0000018c...
...
0188:018c:trace:ole:apartment_findfromtid 0000018c, multi-threaded 1
0188:018c:trace:ole:apartment_findfromtid apt 0034AD80, apt->tid 0000018c
0188:018c:trace:ole:apartment_addref 1880000cafe: before = 2
0188:018c:trace:ole:apartment_addref 1880000cafe: before = 3
0188:018c:trace:ole:apartment_findfromtid 018c => 0034AD80 (multi-threaded)
0188:018c:trace:ole:ipid_to_ifstub ipid {00000001-018c-0188-8366-ab230df0e7d9} (tid 0000018c) => stub_apt 0034AD80
0188:018c:trace:ole:get_stub_manager_from_ipid 0034AD80,{00000001-018c-0188-8366-ab230df0e7d9}
0188:018c:err:ole:get_stub_manager_from_ipid not found for ipid {00000001-018c-0188-8366-ab230df0e7d9}

Server side has both types of apartments in the thread 018c, and apartment_findfromtid()
returns first one which happens to be a multi-threaded one, while stub manager
to serve the client call resides in an apartment-threaded one.

Please let me know if more details is needed.

-- 
Dmitry.



More information about the wine-devel mailing list