Replies: 1 comment 2 replies
-
We've discussed this at various points in times but keep coming back to the same answer that it's really not practical to do. It turns out, COM actually allows reentrancy even in ASTA, as long as COM can see that the call coming back is logically part of the same synchronous chain of events that led to an outgoing call. This is critical to make simple callbacks work, for example, and is a very common pattern. The system that tracks this is called the COM logical thread, and COM transits the logical thread ID on each call and tracks it in TLS. If a component A triggers a call to component B, and B distributes and waits on work in worker threads without using COM (e.g. scheduling thread pool work or making an RPC call), COM doesn't connect the thread ID to the worker threads. So now if the worker thread tries to call back to component A, that call will block waiting for the outbound call to B to finish, and you have a deadlock. This can easily happen with thread pools, service calls, or even blocking on async routines. We spent many person-years tracking & addressing these issues in Windows 8 to make the UWP environment work for ASTA. But another key part of what made this work in UWP was a prohibition on waiting for anything in an ASTA (or for a while, in UWP apps generally) and nested message loops were prohibited (UI or COM). It significantly reduced the scope of the issue. Blocking a thread is not uncommon outside UWP. Many OS APIs, common libraries & tools would deadlock on an ASTA if they weren't already hardened for the UWP ASTA. The limitations and bugs would be a source of endless headaches, doubly so since they would often be very difficult to reason about, reproduce inconsistently, and/or outside of your control to address as an app author. All that is to say it's a "move the mountain an inch to the left" type of problem. Everything needs to be just a little different to make it work properly, which adds up to a prohibitive amount of work. Ben |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! As per the title, is it possible to initialize the ASTA apartment model from classic Win32 applications? That would be handy for reducing possible re-entrancy issues, as explained in https://devblogs.microsoft.com/oldnewthing/20210224-00/?p=104901
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions