M
Madhu Gopinathan
Hi All,
I am faced with a horrible hang problem. I have a COM exe server that executes some tasks. The task execution manager is a thread that manages the pool of threads, which is 4 per processor. Each task is processed in a separate thread. Each of the executer threads is an STA thread, and it goes ahead and executes the task.
No problems are encountered when tasks are executed one at a time, but when multiple tasks are executed simultaneously, I am faced with a hang problem. The task executer thread on its way to executing calls on some VB components which are all apartment threaded.
Say, I give 10 tasks simultaneously for execution. Around four on an average execute successfully, and then the worker threads hang. I checked the call stack of the worker threads and I saw that one of the threads seem to hanging on a call to CoCreateInstance(). This CoCreateInstance call is to a VB component with further calls a LoadLibrary , sometimes for NetApi32.dll, sometimes for Kernel32.dll.
The call stack is shown below.
00 00000188 00000000 00000000 ntdll!ZwWaitForSingleObject+0xb
01 77fcf301 77f86d97 77fcf348 ntdll!RtlpWaitForCriticalSection+0x9e
02 77fcf348 062a2bec 00000000 ntdll!RtlEnterCriticalSection+0x46
03 03ebc718 094dee94 094dee9c ntdll!LdrpLoadDll+0x64
04 03ebc718 094dee94 094dee9c ntdll!LdrLoadDll+0x17
05 7ffabc00 00000000 00000000 KERNEL32!LoadLibraryExW+0x21b
06 21002f24 00000000 00000000 KERNEL32!LoadLibraryExA+0x1d
07 21002f24 00000001 21001da8 KERNEL32!LoadLibraryA+0xa0 <----- This LoadLibrary is for Kernel32, sometimes I get a hang for NetApi32.dll
08 21003070 00000001 094def3c MSVBVM60!GetPvDllFunction+0x34
09 21001da8 00000000 21003070 MSVBVM60!CreateProjExecContext_617+0x6d
0a 6aaaca1f 062a26f0 2100244c MSVBVM60!epiExeRoot::VisitExeRes+0x27
0b 21000000 21010080 00000000 MSVBVM60!CreateProjExecContext_223+0xe8
0c 21000000 21001da8 21001b70 MSVBVM60!EbLoadRunTime_63+0x9e
0d 21001b70 21000000 094df274 MSVBVM60!ProjOpenThread+0x77
0e 21001b70 21000000 6a9ff9b0 MSVBVM60!CVBThreadAction::SetProjectData+0x2e
0f 21000000 00000000 6a9ff9b0 MSVBVM60!CVBThreadAction::Start+0xd4
10 21001b70 21000000 0014bf30 MSVBVM60!CThreadPool::InitDllAccess+0x29
11 21010674 21010670 21001b70 MSVBVM60!VBDllGetClassObject+0x61
12 0014c340 77a55e48 094df3fc ole32!CClassCache::CDllPathEntry:llGetClassObject+0x35
13 00000001 77a55e48 094df3fc ole32!CClassCache::CDllFnPtrMoniker::BindToObject+0x166
14 094df33c 094df3f0 1100580d ole32!CClassCache::SearchForLoadedClass+0x71
15 1100580c 00000000 00000005 ole32!ICoCreateInstanceEx+0xc9 <----- This CoCreateInstance is for a VB component
16 1100580c 00000000 00000005 ole32!CoCreateInstanceEx+0x2b
17 1100582c 061977bc 094df4b4 MSVBVM60!RcmConstructObjectInstance_54+0x112
18 1100582c 061977bc 00000001 MSVBVM60!__vbaNew2+0x20
The call stacks for the other 3 worker threads is as follows
0602fa8c 77f83955 ntdll!ZwWaitForSingleObject+0xb
0602fb00 77f838c6 ntdll!RtlpWaitForCriticalSection+0x9e
0602fb08 6a9e7412 ntdll!RtlEnterCriticalSection+0x46
0602fd7c 6a9e6e06 MSVBVM60!TipUnloadProject+0x20
0602fd90 6a9e6b49 MSVBVM60!ProjFDeleteThread+0x6e
0602fdac 6aa5770c MSVBVM60!CVBThreadAction::CleanupProjData+0x6c
0602fdbc 6aa0ee69 MSVBVM60!CThreadPool::CleanupAtDllDetach+0x14
0602fdd4 77f82fc9 MSVBVM60!UserDllMain_26+0x39
0602fdfc 77f84697 ntdll!LdrpCallInitRoutine+0x14
0602fe50 77e8762c ntdll!LdrShutdownThread+0xa3
0602feb8 004e88f6 KERNEL32!ExitThread+0x53
0602ff18 005618a6 WFExec!WFTaskExecuterThread::ThreadProc+0xbe [W:\bvAdminForWindows\Rules\Components\Workflow\WFCore\WFTaskExecuterThread.cpp @ 63]
0602ff80 7800a3c0 WFExec!Thread::ThreadProc+0x47 [W:\bvAdminShared\Reusable\Components\REReusableLib\Thread.cpp @ 106]
0602ffb4 77e8758a MSVCRT!_beginthreadex+0xca
0602ffec 00000000 KERNEL32!BaseThreadStart+0x52
The hang does not occur if I make the threading model of the VB components, single threaded instead of apartment thread. However, I need them to be apartment threaded due to impersonation reasons.
Can someone please help me here?
Regards,
Madhu
I am faced with a horrible hang problem. I have a COM exe server that executes some tasks. The task execution manager is a thread that manages the pool of threads, which is 4 per processor. Each task is processed in a separate thread. Each of the executer threads is an STA thread, and it goes ahead and executes the task.
No problems are encountered when tasks are executed one at a time, but when multiple tasks are executed simultaneously, I am faced with a hang problem. The task executer thread on its way to executing calls on some VB components which are all apartment threaded.
Say, I give 10 tasks simultaneously for execution. Around four on an average execute successfully, and then the worker threads hang. I checked the call stack of the worker threads and I saw that one of the threads seem to hanging on a call to CoCreateInstance(). This CoCreateInstance call is to a VB component with further calls a LoadLibrary , sometimes for NetApi32.dll, sometimes for Kernel32.dll.
The call stack is shown below.
00 00000188 00000000 00000000 ntdll!ZwWaitForSingleObject+0xb
01 77fcf301 77f86d97 77fcf348 ntdll!RtlpWaitForCriticalSection+0x9e
02 77fcf348 062a2bec 00000000 ntdll!RtlEnterCriticalSection+0x46
03 03ebc718 094dee94 094dee9c ntdll!LdrpLoadDll+0x64
04 03ebc718 094dee94 094dee9c ntdll!LdrLoadDll+0x17
05 7ffabc00 00000000 00000000 KERNEL32!LoadLibraryExW+0x21b
06 21002f24 00000000 00000000 KERNEL32!LoadLibraryExA+0x1d
07 21002f24 00000001 21001da8 KERNEL32!LoadLibraryA+0xa0 <----- This LoadLibrary is for Kernel32, sometimes I get a hang for NetApi32.dll
08 21003070 00000001 094def3c MSVBVM60!GetPvDllFunction+0x34
09 21001da8 00000000 21003070 MSVBVM60!CreateProjExecContext_617+0x6d
0a 6aaaca1f 062a26f0 2100244c MSVBVM60!epiExeRoot::VisitExeRes+0x27
0b 21000000 21010080 00000000 MSVBVM60!CreateProjExecContext_223+0xe8
0c 21000000 21001da8 21001b70 MSVBVM60!EbLoadRunTime_63+0x9e
0d 21001b70 21000000 094df274 MSVBVM60!ProjOpenThread+0x77
0e 21001b70 21000000 6a9ff9b0 MSVBVM60!CVBThreadAction::SetProjectData+0x2e
0f 21000000 00000000 6a9ff9b0 MSVBVM60!CVBThreadAction::Start+0xd4
10 21001b70 21000000 0014bf30 MSVBVM60!CThreadPool::InitDllAccess+0x29
11 21010674 21010670 21001b70 MSVBVM60!VBDllGetClassObject+0x61
12 0014c340 77a55e48 094df3fc ole32!CClassCache::CDllPathEntry:llGetClassObject+0x35
13 00000001 77a55e48 094df3fc ole32!CClassCache::CDllFnPtrMoniker::BindToObject+0x166
14 094df33c 094df3f0 1100580d ole32!CClassCache::SearchForLoadedClass+0x71
15 1100580c 00000000 00000005 ole32!ICoCreateInstanceEx+0xc9 <----- This CoCreateInstance is for a VB component
16 1100580c 00000000 00000005 ole32!CoCreateInstanceEx+0x2b
17 1100582c 061977bc 094df4b4 MSVBVM60!RcmConstructObjectInstance_54+0x112
18 1100582c 061977bc 00000001 MSVBVM60!__vbaNew2+0x20
The call stacks for the other 3 worker threads is as follows
0602fa8c 77f83955 ntdll!ZwWaitForSingleObject+0xb
0602fb00 77f838c6 ntdll!RtlpWaitForCriticalSection+0x9e
0602fb08 6a9e7412 ntdll!RtlEnterCriticalSection+0x46
0602fd7c 6a9e6e06 MSVBVM60!TipUnloadProject+0x20
0602fd90 6a9e6b49 MSVBVM60!ProjFDeleteThread+0x6e
0602fdac 6aa5770c MSVBVM60!CVBThreadAction::CleanupProjData+0x6c
0602fdbc 6aa0ee69 MSVBVM60!CThreadPool::CleanupAtDllDetach+0x14
0602fdd4 77f82fc9 MSVBVM60!UserDllMain_26+0x39
0602fdfc 77f84697 ntdll!LdrpCallInitRoutine+0x14
0602fe50 77e8762c ntdll!LdrShutdownThread+0xa3
0602feb8 004e88f6 KERNEL32!ExitThread+0x53
0602ff18 005618a6 WFExec!WFTaskExecuterThread::ThreadProc+0xbe [W:\bvAdminForWindows\Rules\Components\Workflow\WFCore\WFTaskExecuterThread.cpp @ 63]
0602ff80 7800a3c0 WFExec!Thread::ThreadProc+0x47 [W:\bvAdminShared\Reusable\Components\REReusableLib\Thread.cpp @ 106]
0602ffb4 77e8758a MSVCRT!_beginthreadex+0xca
0602ffec 00000000 KERNEL32!BaseThreadStart+0x52
The hang does not occur if I make the threading model of the VB components, single threaded instead of apartment thread. However, I need them to be apartment threaded due to impersonation reasons.
Can someone please help me here?
Regards,
Madhu