EDN Admin
Well-known member
Hi all,
I have one COM object whose threading model is defined as neutral. What I understood about neutral apartment is that accessing the neutral coclass instances doesnt require context switch. the call will be executed in the callers thread, which is different from the STA apartment.
but recently i met one hung issue in my application. the UI thread keeps waiting for one lock, but the worker thread who holds the lock is making call to a neutral object but directing the call to the STA thread. the call stack looks like below:ChildEBP RetAddr
1ff4e35c 75ec15e9 ntdll!NtWaitForMultipleObjects+0x15
1ff4e3f8 74fc162d KERNELBASE!WaitForMultipleObjectsEx+0x100
1ff4e440 76a703da kernel32!WaitForMultipleObjectsExImplementation+0xe0
1ff4e494 74d53520 user32!RealMsgWaitForMultipleObjectsEx+0x14d
1ff4e4c0 74d536a5 ole32!CCliModalLoop::BlockFn+0xa1
1ff4e4e8 74d4daa0 ole32!ModalLoop+0x5b
1ff4e4f8 74e6a91b ole32!SwitchSTA+0x21
1ff4e528 74e6c05f ole32!CRpcChannelBuffer::SwitchAptAndDispatchCall+0x135
1ff4e608 74d536ee ole32!CRpcChannelBuffer::SendReceive2+0xef
1ff4e624 74d5cc48 ole32!CCliModalLoop::SendReceive+0x1e
1ff4e6a0 74d47fd3 ole32!CAptRpcChnl::SendReceive+0x73
1ff4e6f4 74e6bf75 ole32!CCtxComChnl::SendReceive+0x95
1ff4e710 767b414b ole32!NdrExtpProxySendReceive+0x49
1ff4e71c 76830149 rpcrt4!NdrpProxySendReceive+0xe
1ff4eb30 74e6ba02 rpcrt4!NdrClientCall2+0x1a6
1ff4eb50 74d5c95d ole32!ObjectStublessClient+0xa2
1ff4eb60 74d48bd8 ole32!ObjectStubless+0xf
1ff4ebe8 74d3d054 ole32!CObjectContext::InternalContextCallback+0x128
1ff4ec38 71e59ccb ole32!CObjectContext::ContextCallback+0x92
WARNING: Stack unwind information not available. Following frames may be wrong.
1ff4ec84 71e5a8b6 mscorwks!LogHelp_NoGuiOnAssert+0x1eab3
this confused me a lot about the understanding of neutral object. maybe there is something wrong in my code. but i was wondering if there is any case that can cause this happen? Or something I missed?
Another wired thing is that if i step into this call, then i dont see this SwitchSTA happen. it just works as my exception to neutral object. the above call stack is caught by windbg when the hung happened
Thanks a lot.
View the full article
I have one COM object whose threading model is defined as neutral. What I understood about neutral apartment is that accessing the neutral coclass instances doesnt require context switch. the call will be executed in the callers thread, which is different from the STA apartment.
but recently i met one hung issue in my application. the UI thread keeps waiting for one lock, but the worker thread who holds the lock is making call to a neutral object but directing the call to the STA thread. the call stack looks like below:ChildEBP RetAddr
1ff4e35c 75ec15e9 ntdll!NtWaitForMultipleObjects+0x15
1ff4e3f8 74fc162d KERNELBASE!WaitForMultipleObjectsEx+0x100
1ff4e440 76a703da kernel32!WaitForMultipleObjectsExImplementation+0xe0
1ff4e494 74d53520 user32!RealMsgWaitForMultipleObjectsEx+0x14d
1ff4e4c0 74d536a5 ole32!CCliModalLoop::BlockFn+0xa1
1ff4e4e8 74d4daa0 ole32!ModalLoop+0x5b
1ff4e4f8 74e6a91b ole32!SwitchSTA+0x21
1ff4e528 74e6c05f ole32!CRpcChannelBuffer::SwitchAptAndDispatchCall+0x135
1ff4e608 74d536ee ole32!CRpcChannelBuffer::SendReceive2+0xef
1ff4e624 74d5cc48 ole32!CCliModalLoop::SendReceive+0x1e
1ff4e6a0 74d47fd3 ole32!CAptRpcChnl::SendReceive+0x73
1ff4e6f4 74e6bf75 ole32!CCtxComChnl::SendReceive+0x95
1ff4e710 767b414b ole32!NdrExtpProxySendReceive+0x49
1ff4e71c 76830149 rpcrt4!NdrpProxySendReceive+0xe
1ff4eb30 74e6ba02 rpcrt4!NdrClientCall2+0x1a6
1ff4eb50 74d5c95d ole32!ObjectStublessClient+0xa2
1ff4eb60 74d48bd8 ole32!ObjectStubless+0xf
1ff4ebe8 74d3d054 ole32!CObjectContext::InternalContextCallback+0x128
1ff4ec38 71e59ccb ole32!CObjectContext::ContextCallback+0x92
WARNING: Stack unwind information not available. Following frames may be wrong.
1ff4ec84 71e5a8b6 mscorwks!LogHelp_NoGuiOnAssert+0x1eab3
this confused me a lot about the understanding of neutral object. maybe there is something wrong in my code. but i was wondering if there is any case that can cause this happen? Or something I missed?
Another wired thing is that if i step into this call, then i dont see this SwitchSTA happen. it just works as my exception to neutral object. the above call stack is caught by windbg when the hung happened
Thanks a lot.
View the full article