473,508 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hang problem... Help Please!!

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::DllGetClassObjec t+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\WFC ore\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
Nov 17 '05 #1
4 6193
This is a typical LoaderLock deadlock.
With the help of the system debuggers (ntsd/cdb/windbg)
you can use the `!cs' command to see who is owning the loader lock,
and from that point you should be able to figure out how to move forward
and/or break the deadlock.

Typically this happens because a component is waiting for a thread in
DllMain,
or it's performing a blocking RPC call from DllMain.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Madhu Gopinathan" <ma*******@rediffmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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::DllGetClassObjec t+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\WFC ore\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
Nov 17 '05 #2
Hi Ivan,
Thanks for your quick response.
I did not come across any !cs command in windbg. Are you talking about
the !critlist command exported from the sieextpub.dll? If so, I do get a
deadlock situation sometimes, which tells me which thread is owning the
critical section that the others threads are blocking on. The two call
stacks I have given are those of the deadlocked threads.

However I cannot decipher any information from them because they seem to
be deadlocking in the system DLLs. One on the call to ExitThread, while the
other in LoadLibrary(for Kernel32).

Can you help me to unmangle the call stack? Any help will be greatly
appreciated.

Thanks again,
Madhu.

"Ivan Brugiolo [MSFT]" <iv******@online.microsoft.com> wrote in message
news:O5**************@TK2MSFTNGP11.phx.gbl...
This is a typical LoaderLock deadlock.
With the help of the system debuggers (ntsd/cdb/windbg)
you can use the `!cs' command to see who is owning the loader lock,
and from that point you should be able to figure out how to move forward
and/or break the deadlock.

Typically this happens because a component is waiting for a thread in
DllMain,
or it's performing a blocking RPC call from DllMain.

--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Madhu Gopinathan" <ma*******@rediffmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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::DllGetClassObjec t+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\WFC ore\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

Nov 17 '05 #3
Both the `!cs' and the `!locks' command are availalble.

Upon closer inspection, the VB runtime is most likely at fault,
since it's waiting for a critical section in the DllMain(THREAD_DETACH) code
path.
The loader lock is held while performing thread shutdown anyway, and then
the runtime is holding one more critical section.
The thread waiting on the LoaderLock inside LoadLibrary has an uncomplete
stack,
but most likely somewhere down the stack there is a code path
that holds the same critical section that is waited in the THREAD_DETACH
code path.

if you could report the output of the `~*kb 100' command in cdb/ntsd/windbg,
maybe there are more hints to support this thesis.

I'm not at all a VB expert, but maybe you can avoid this by preventing the
LoadLibrary call
somewhere in the "Project Startup" code-path.
Maybe there are certain restriction in causing the VB runtime to calll
LoadLibrary/GetProcaddress
in certain places of the VB code, the same way there are restrictions
about Loader-Lock sensitive options while holding other locks in the
traditional Win32.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Madhu Gopinathan" <ma*******@rediffmail.com> wrote in message
news:uc**************@TK2MSFTNGP10.phx.gbl...
Hi Ivan,
Thanks for your quick response.
I did not come across any !cs command in windbg. Are you talking about
the !critlist command exported from the sieextpub.dll? If so, I do get a
deadlock situation sometimes, which tells me which thread is owning the
critical section that the others threads are blocking on. The two call
stacks I have given are those of the deadlocked threads.

However I cannot decipher any information from them because they seem to be deadlocking in the system DLLs. One on the call to ExitThread, while the other in LoadLibrary(for Kernel32).

Can you help me to unmangle the call stack? Any help will be greatly
appreciated.

Thanks again,
Madhu.

"Ivan Brugiolo [MSFT]" <iv******@online.microsoft.com> wrote in message
news:O5**************@TK2MSFTNGP11.phx.gbl...
This is a typical LoaderLock deadlock.
With the help of the system debuggers (ntsd/cdb/windbg)
you can use the `!cs' command to see who is owning the loader lock,
and from that point you should be able to figure out how to move forward
and/or break the deadlock.

Typically this happens because a component is waiting for a thread in
DllMain,
or it's performing a blocking RPC call from DllMain.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Madhu Gopinathan" <ma*******@rediffmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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::DllGetClassObjec t+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\WFC ore\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


Nov 17 '05 #4
Hi Ivan,
Thanks for your immediate reply.
I tried '!cs' command in Windbg version 6.2.0007.4, but it returned "No
export !cs found". Do I have to load some helper dll like sieextpub.dll for
this export?

I figured the problem to be occuring because the VB component creates
some global apartment threaded objects on one of the worker threads, while
the other worker threads refer to the instances created on the first thread.
After task execution, the thread that created the global objects dies, while
the other threads that still refer to the global references to the objects
created on first thread, hang upon calls to that objects, (because they have
posted messages to the window of thread 1, while not getting response in
their message queue). I hope you understand the problem.

That is the reason why everything was working when I made the threading
model of the VB component "Single threaded" instead of "Apartment threaded",
because all objects were created on the main thread, which remained alive as
long as the process was executing.

But, I still don't understand how the Loader has been locked here? Can
you shed some light on the same? Do you think that the reason I think for
the hang is right and logical enough?

Thanks again.
Regards,
Madhu.
"Ivan Brugiolo [MSFT]" <iv******@online.microsoft.com> wrote in message
news:ea**************@TK2MSFTNGP09.phx.gbl...
Both the `!cs' and the `!locks' command are availalble.

Upon closer inspection, the VB runtime is most likely at fault,
since it's waiting for a critical section in the DllMain(THREAD_DETACH) code path.
The loader lock is held while performing thread shutdown anyway, and then
the runtime is holding one more critical section.
The thread waiting on the LoaderLock inside LoadLibrary has an uncomplete
stack,
but most likely somewhere down the stack there is a code path
that holds the same critical section that is waited in the THREAD_DETACH
code path.

if you could report the output of the `~*kb 100' command in cdb/ntsd/windbg, maybe there are more hints to support this thesis.

I'm not at all a VB expert, but maybe you can avoid this by preventing the
LoadLibrary call
somewhere in the "Project Startup" code-path.
Maybe there are certain restriction in causing the VB runtime to calll
LoadLibrary/GetProcaddress
in certain places of the VB code, the same way there are restrictions
about Loader-Lock sensitive options while holding other locks in the
traditional Win32.

--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Madhu Gopinathan" <ma*******@rediffmail.com> wrote in message
news:uc**************@TK2MSFTNGP10.phx.gbl...
Hi Ivan,
Thanks for your quick response.
I did not come across any !cs command in windbg. Are you talking about
the !critlist command exported from the sieextpub.dll? If so, I do get a
deadlock situation sometimes, which tells me which thread is owning the
critical section that the others threads are blocking on. The two call
stacks I have given are those of the deadlocked threads.

However I cannot decipher any information from them because they seem
to
be deadlocking in the system DLLs. One on the call to ExitThread, while the
other in LoadLibrary(for Kernel32).

Can you help me to unmangle the call stack? Any help will be greatly
appreciated.

Thanks again,
Madhu.

"Ivan Brugiolo [MSFT]" <iv******@online.microsoft.com> wrote in message
news:O5**************@TK2MSFTNGP11.phx.gbl...
This is a typical LoaderLock deadlock.
With the help of the system debuggers (ntsd/cdb/windbg)
you can use the `!cs' command to see who is owning the loader lock,
and from that point you should be able to figure out how to move forward and/or break the deadlock.

Typically this happens because a component is waiting for a thread in
DllMain,
or it's performing a blocking RPC call from DllMain.

--
This posting is provided "AS IS" with no warranties, and confers no

rights.
Use of any included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
"Madhu Gopinathan" <ma*******@rediffmail.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
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::DllGetClassObjec t+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\WFC ore\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



Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2071
by: changxun | last post by:
I'm running a simulation with one client machine and four server machines (all in the same LAN and running Fedora Core 2 with kernel 2.6.5-1.358smp). The client sends about 1.2 million requests...
1
1622
by: funfair | last post by:
HI,EVERY ONE first problem, i have create a database in access 2003 it worked fine untill i have format my laptop . now im working on office 2003 on windows xp and i have norton 2006 but im...
2
1447
by: Radu | last post by:
Hi. I am creating a user control in vs2005 which is supposed to provide a fancy gradient background - in theory, you just drop it on a form, you set the start/end colors, the gradient type, and...
3
11402
by: ilia | last post by:
Hi All, I am a newbie in terms of Javascript, I found some code on the net to swap rows in a table using innerHTML, this works fine in Firefox but IE is complaining, after some googling around I...
3
2844
by: stclaus | last post by:
Hi, I'm currently experiencing a problem using sessions under php 4.4.2. I store variables and objects inside session variables, and all works well under php 5.x, but when I upload those pages to...
4
1292
by: Alan | last post by:
Hi, I m working on thesis on mechanical engieering. I m using C to solve a particualr problem. I have this code underneath which is giving me problems: for (t=0;t<=maxt;t++){ printf("testing...
0
1459
by: nt91rx78 | last post by:
Our college changes 18 weeks semester to 16 semester, so our CS professor cannot finish teaching the last important chapter which is related with my problw\em. This is program C problem Anyone...
1
1406
by: icetalks | last post by:
have a look at this code , its for logging the user in after checking his UserName and Password. dim check as boolean = false ... ... If txtUserName.Text.Length = 0 And txtPass.Text.Length =...
0
1359
by: sa6113 | last post by:
I want to connect to a Windows machine in my network , using ssh, I use paramiko but I have problem in authentication, would you please help me? 1- I have installed freeSSHD in server machine? Is...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7385
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.