Hi Everyone.
I am way out of my depth in this part of the forum and do hope you can give me some guidance on what I should do.
Upon opening a second Excel file Excel 2007 hangs and eventually shows
"Microsoft Excel is waiting for another application to complete an OLE action"
This I understand is caused because the main UI or STA thread is blocked. It appears to be blocked by my addin or I think by what VSTO does as a result of my addin.
Debugging in Visual Studio and attaching to Excel as it opens a file shows that the main STA thread is waiting for a join or another thread and I think shows
> mscorlib.dll!System.GC.WaitForPendingFinalizers() Line 320 + 0x1b bytes C#
I don't call nor use GC at all. It looks like VSTO is doing it.
Now I have downloaded and installed windbg and hope the following is how you guys can help me to understand what is going on. I cannot get Office or VSTO symbols with windbg. I got some of them when Visual Studio downloaded them but some are still missing.
So a simple !analyze -hang does not work. I am able to use sos.dll with clr.
!Threads shows the following;
ThreadCount: 4 UnstartedThread: 0 BackgroundThread: 4 PendingThread: 0 DeadThread: 0 Hosted Runtime: no PreEmptive GC Alloc Lock ID OSID ThreadOBJ State GC Context Domain Count APT Exception 0 1 83c 005a30a0 2004220 Enabled 06ea12f8:06ea1fe8 0667f250 0 STA 11 2 1878 005ae200 b220 Enabled 00000000:00000000 005944d8 0 MTA (Finalizer) 12 3 1900 066831e8 1220 Enabled 00000000:00000000 005944d8 0 Ukn 18 4 1668 06743ab0 220 Enabled 00000000:00000000 005944d8 0 STA
Thread 0 is the main UI thread and I assume the one that must be blocked.
kb on Thread 0
ChildEBP RetAddr Args to Child 003bcb44 767815e9 00000002 003bcb94 00000001 ntdll!NtWaitForMultipleObjects+0x15 003bcbe0 764519fc 003bcb94 003bcc08 00000000 KERNELBASE!WaitForMultipleObjectsEx+0x100 003bcc28 765f086a 00000002 7efde000 00000000 kernel32!WaitForMultipleObjectsExImplementation+0xe0 003bcc7c 76ab2bf1 00000050 00591048 ffffffff USER32!RealMsgWaitForMultipleObjectsEx+0x14d 003bcca8 76aa202d 00591048 ffffffff 003bccd0 ole32!CCliModalLoop::BlockFn+0xa1 [d:\w7rtm\com\ole32\com\dcomrem\callctrl.cxx @ 1222] 003bcd28 720ba2bd 00000002 ffffffff 00000001 ole32!CoWaitForMultipleHandles+0xcd [d:\w7rtm\com\ole32\com\dcomrem\sync.cxx @ 109] 003bcd90 720ba249 00000001 00591048 00000000 clr!MsgWaitHelper+0x80 003bcdb0 720eea17 00000001 00591048 00000000 clr!Thread::DoAppropriateAptStateWait+0x39 003bce44 720eead8 00000001 00591048 00000000 clr!Thread::DoAppropriateWaitWorker+0x17d 003bceb0 720eeb57 00000001 00591048 00000000 clr!Thread::DoAppropriateWait+0x60 003bcf04 71f7173e ffffffff 00000001 00000000 clr!CLREvent::WaitEx+0x106 003bcf18 72047660 ffffffff 00000001 00000000 clr!CLREvent::Wait+0x19 003bcf74 72107049 ffffffff aa761eae 003bcfc0 clr!WKS::GCHeap::FinalizerThreadWait+0x114 003bcfb4 718823d4 aa0fcc08 71f55c40 003bd53c clr!GCInterface::WaitForPendingFinalizers+0x71 003bcff4 71f5219b 76b15b5c 00000000 003bd080 mscorlib_ni+0x7c23d4 003bd004 71f8a7aa 003bd0d0 00000000 003bd0a0 clr!CallDescrWorker+0x33 003bd080 71f8a94c 003bd0d0 00000000 003bd0a0 clr!CallDescrWorkerWithHandler+0x8e 003bd1c0 71f8a981 718823a8 003bd2e4 003bd490 clr!MethodDesc::CallDescr+0x194 003bd1dc 71f8a9a1 718823a8 003bd2e4 003bd490 clr!MethodDesc::CallTargetWorker+0x21 003bd1f4 71fd8d54 003bd490 aa7602a2 003bd764 clr!MethodDescCallSite::Call_RetArgSlot+0x1c 003bd3b8 71fd90a6 71145d28 718823a8 710c1000 clr!CallWithValueTypes_RetArgSlotWrapper+0x5c 003bd67c 71fd9268 71145d28 00000000 00000000 clr!InvokeImpl+0x621 003bd748 7137d8c9 005a30a0 00000096 003bd764 clr!RuntimeMethodHandle::InvokeMethodFast+0x180 003bd79c 7137d610 06e9add4 00000096 06e9b50c mscorlib_ni+0x2bd8c9 003bd7d4 7137c22d 00000000 00000000 00000000 mscorlib_ni+0x2bd610 003bd7fc 71316bcc 00000000 00000000 06e897f4 mscorlib_ni+0x2bc22d 003bd950 71885fbd 00000000 00000000 00000000 mscorlib_ni+0x256bcc 003bd974 718ff890 00000000 00000000 00000000 mscorlib_ni+0x7c5fbd 003bd9e8 71f52581 003bddb8 00000000 005a0000 mscorlib_ni+0x83f890 003bda14 72045943 718ff7d0 71885fa0 06e9add4 clr!COMToCLRDispatchHelper+0x28 003bdaa8 72045a1c 71885fa0 06e9add4 00000001 clr!BaseWrapper<Stub *,FunctionBase<Stub *,&DoNothing<Stub *>,&StubRelease<Stub>,2>,0,&CompareDefault<Stub *>,2>::~BaseWrapper<Stub *,FunctionBase<Stub *,&DoNothing<Stub *>,&StubRelease<Stub>,2>,0,&CompareDefault<Stub *>,2>+0xfa 003bdacc 72045a82 005a30a0 003bdd60 05bdf9e0 clr!COMToCLRWorkerBody+0xb4 003bdb24 72046571 005a30a0 003bdd60 05bdf9e0 clr!COMToCLRWorkerDebuggerWrapper+0x34 003bdd34 03fca182 005a30a0 003bdd60 aa0fcc08 clr!COMToCLRWorker+0x614 WARNING: Frame IP not in any known module. Following frames may be wrong. 003bdd48 6928980d 003bdd90 003bddb8 00000000 0x3fca182 003bdddc 6928997a 05bdf9f8 00000000 00000621 VSTOLoader!DllRegisterServer+0x61bb 003bde0c 69277ccb 05c3e438 00000000 00000001 VSTOLoader!DllRegisterServer+0x6328 003bde20 692617de 00000621 00000003 003bdebc VSTOLoader!DllCanUnloadNow+0xb1cf 003bde34 2f421899 06436aa8 00000621 2f301ad4 VSTOLoader+0x17de 003bde88 2f4217f7 00000621 003bdebc 06058150 EXCEL!Ordinal40+0x221899 003bdecc 2f585aa1 00000621 06058168 00000000 EXCEL!Ordinal40+0x2217f7 003bdef4 2f3d1dad 00000001 00000012 00000000 EXCEL!Ordinal40+0x385aa1 003be1b0 2f328830 003beb04 00000012 00000000 EXCEL!Ordinal40+0x1d1dad 003be46c 2f32961e 00000000 003beb04 00000012 EXCEL!Ordinal40+0x128830 003be490 2f230ae1 003beb04 00000012 00000000 EXCEL!Ordinal40+0x12961e 003be6e0 2fb4ab31 00000001 003beb04 00000012 EXCEL!Ordinal40+0x30ae1 003bf7a4 2ff2f2cd 0670dba0 003bf818 0000fffe EXCEL!Ordinal40+0x94ab31 003bfc4c 2f5d20f9 003bfcb0 00000001 000080df EXCEL!LPenHelper+0x12f485 003bfcec 2f2282fa 00000000 30163708 765f0afa EXCEL!Ordinal40+0x3d20f9 003bfdd4 2f203b60 00000000 30163c58 004c4095 EXCEL!Ordinal40+0x282fa 003bfe44 2f203874 2f200000 00000000 004c4095 EXCEL!Ordinal40+0x3b60 003bfed4 7645336a 7efde000 003bff20 772bbf32 EXCEL!Ordinal40+0x3874 003bfee0 772bbf32 7efde000 7741c403 00000000 kernel32!BaseThreadInitThunk+0xe 003bff20 772bbf05 2f202f7c 7efde000 00000000 ntdll!__RtlUserThreadStart+0x70 003bff38 00000000 2f202f7c 7efde000 00000000 ntdll!_RtlUserThreadStart+0x1b
kb on Thread 11
ChildEBP RetAddr Args to Child 0905ee1c 7678149d 000007a0 00000000 00000000 ntdll!NtWaitForSingleObject+0x15 0905ee88 76451194 000007a0 ffffffff 00000000 KERNELBASE!WaitForSingleObjectEx+0x98 0905eea0 76451148 000007a0 ffffffff 00000000 kernel32!WaitForSingleObjectExImplementation+0x75 0905eeb4 76aa7690 000007a0 ffffffff 00542008 kernel32!WaitForSingleObject+0x12 0905eed8 76bca4d1 00542730 066d2d70 0905efe4 ole32!GetToSTA+0xad [d:\w7rtm\com\ole32\com\dcomrem\chancont.cxx @ 133] 0905ef08 76bccef0 0905efd0 0905f0f8 00542008 ole32!CRpcChannelBuffer::SwitchAptAndDispatchCall+0x140 [d:\w7rtm\com\ole32\com\dcomrem\channelb.cxx @ 4419] 0905efe8 76ac9d01 00542008 0905f0f8 0905f0e0 ole32!CRpcChannelBuffer::SendReceive2+0xef [d:\w7rtm\com\ole32\com\dcomrem\channelb.cxx @ 4076] 0905f064 76aa792b 00542008 0905f0f8 0905f0e0 ole32!CAptRpcChnl::SendReceive+0xaf [d:\w7rtm\com\ole32\com\dcomrem\callctrl.cxx @ 603] 0905f0b8 76bcce06 00000001 0b223f98 0905f0e0 ole32!CCtxComChnl::SendReceive+0x95 [d:\w7rtm\com\ole32\com\dcomrem\ctxchnl.cxx @ 679] 0905f0d4 75f5420b 0b217684 0905f124 75fd0149 ole32!NdrExtpProxySendReceive+0x49 [d:\w7rtm\com\rpc\ndrole\proxy.cxx @ 1932] 0905f0e0 75fd0149 a3604c8f 0905f52c 0700022b RPCRT4!NdrpProxySendReceive+0xe 0905f4f4 76bcc8e2 76adfa10 76ae49b8 0905f52c RPCRT4!NdrClientCall2+0x1a6 0905f514 76ac98ad 0000000c 00000008 0905f5ac ole32!ObjectStublessClient+0xa2 [d:\w7rtm\com\rpc\ndrole\i386\stblsclt.cxx @ 474] 0905f524 76aa805c 0b217684 0905f560 00000001 ole32!ObjectStubless+0xf [d:\w7rtm\com\rpc\ndrole\i386\stubless.asm @ 154] 0905f5ac 76a9d4b4 00521408 720c90da 0905f6b8 ole32!CObjectContext::InternalContextCallback+0x128 [d:\w7rtm\com\ole32\com\dcomrem\context.cxx @ 4299] 0905f5fc 720c879c 00521418 720c90da 0905f6b8 ole32!CObjectContext::ContextCallback+0x92 [d:\w7rtm\com\ole32\com\dcomrem\context.cxx @ 4184] 0905f714 720c8837 720c857a 0905f770 a3482652 clr!CtxEntry::EnterContext+0x312 0905f748 720c8665 00000000 a3482682 725695c8 clr!RCWCleanupList::ReleaseRCWListInCorrectCtx+0xdf 0905f798 720b1536 a34826fe 00000000 005ae200 clr!RCWCleanupList::CleanupAllWrappers+0xff 0905f7e4 720af497 00000001 0905f930 71fc76b3 clr!SyncBlockCache::CleanupSyncBlocks+0xde 0905f7f0 71fc76b3 005ae200 0905f930 00591088 clr!Thread::DoExtraWorkForFinalizer+0x3b 0905f804 720ef845 00000001 0905f8e8 005ae200 clr!WKS::GCHeap::FinalizerThreadWorker+0x9d 0905f818 720ef8c7 0905f930 a34829d2 0905f930 clr!Thread::DoExtraWorkForFinalizer+0x114 0905f8c8 720ef982 0905f930 a3482832 00000000 clr!Thread::ShouldChangeAbortToUnload+0x101 0905f928 720e5c8f 00000000 005944d8 00000000 clr!Thread::ShouldChangeAbortToUnload+0x399 0905f94c 720e5ca2 71fc7628 00000008 0905f994 clr!ManagedThreadBase_NoADTransition+0x35 0905f95c 720901ba 71fc7628 a348288e 00000000 clr!ManagedThreadBase::FinalizerBase+0xf 0905f994 720ef648 00000000 00000000 00000000 clr!WKS::GCHeap::FinalizerThreadStart+0x10c 0905fa34 7645336a 00591088 0905fa80 772bbf32 clr!Thread::intermediateThreadProc+0x4b 0905fa40 772bbf32 00591088 7e7fc1a3 00000000 kernel32!BaseThreadInitThunk+0xe 0905fa80 772bbf05 720ef600 00591088 00000000 ntdll!__RtlUserThreadStart+0x70 0905fa98 00000000 720ef600 00591088 00000000 ntdll!_RtlUserThreadStart+0x1b
I believe that the next step is to look at the clrstack on Thread 0
!clrstack on Thread 0
0:000> !clrstack OS Thread Id: 0x83c (0) Child SP IP Call Site 003bcfc0 772a015d [InlinedCallFrame: 003bcfc0] System.GC._WaitForPendingFinalizers() 003bcfbc 718823d4 System.GC.WaitForPendingFinalizers() 003bd53c 71f5219b [DebuggerU2MCatchHandlerFrame: 003bd53c] 003bd508 71f5219b [CustomGCFrame: 003bd508] 003bd4dc 71f5219b [GCFrame: 003bd4dc] 003bd4c0 71f5219b [GCFrame: 003bd4c0] 003bd6e4 71f5219b [HelperMethodFrame_PROTECTOBJ: 003bd6e4] System.RuntimeMethodHandle._InvokeMethodFast(System.IRuntimeMethodInfo, System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeType) 003bd760 7137d8c9 System.RuntimeMethodHandle.InvokeMethodFast(System.IRuntimeMethodInfo, System.Object, System.Object[], System.Signature, System.Reflection.MethodAttributes, System.RuntimeType) 003bd7b4 7137d610 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean) 003bd7f0 7137c22d System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) 003bd814 71316bcc System.RuntimeType.InvokeMember(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object, System.Object[], System.Reflection.ParameterModifier[], System.Globalization.CultureInfo, System.String[]) 003bd974 71885fbd System.Type.InvokeMember(System.String, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object, System.Object[]) 003bd98c 718ff890 DomainNeutralILStubClass.IL_STUB_COMtoCLR(IntPtr, Int32, IntPtr, System.StubHelpers.NativeVariant, IntPtr, IntPtr) 003bdb64 71f52581 [GCFrame: 003bdb64] 003bdbd4 71f52581 [ContextTransitionFrame: 003bdbd4] 003bdc08 71f52581 [GCFrame: 003bdc08] 003bdd60 71f52581 [ComMethodFrame: 003bdd60]
I would very much appreciate some help. Maybe you could point out to me in the above the call that is most important and how then in windbg to find out maybe the handle or callee to narrow down where the problem is coming from.