develooper Front page | perl.perl5.porters | Postings from September 2012

RE: fix RT#88840, don't terminate a child fork psuedo process inDLL Loader Lock

Thread Next
From:
bulk 88
Date:
September 8, 2012 09:01
Subject:
RE: fix RT#88840, don't terminate a child fork psuedo process inDLL Loader Lock
Message ID:
COL115-W63321B5A4B7CE95BF06A06DFAE0@phx.gbl



________________________________
> From: Mike.B.Huang@emc.com 
> To: bulk88@hotmail.com 
> Date: Sat, 8 Sep 2012 00:12:21 -0400 
> Subject: fix RT#88840, don't terminate a child fork psuedo process in  
> DLL Loader Lock 
>  
>  
> Hi Daniel, 
>  
>  
>  
> I saw that you fixed RT#88840 on August. Does your code fix my test  
> program attached? 
>  
>  
>  
> I suffered a hang issue when I am developing an application using fork  
> and backticks on Windows. 
>  
> The application hung randomly on Windows with ActivePerl 5.14 and 5.16.  
> I googled a test program to 
>  
> Verify whether ActivePerl is stable enough and found that it could be  
> reproduced easily with this loop, 
>  
> “for /L %i in (1 1 1000) do perl.exe thread_hang.pl” 
>  
>  
>  
> Another question, would you tell me how to setup the build environment  
> of perl? I just followed the 
>  
> README.win32 on my windows 7 with Visual Studio 2010, but nmake just  
> didn’t work. Here is a piece of 
>  
> The log, 
>  
>  
>  
> ..\generate_uudmap.c(77) : warning C4996: 'fopen': This function or  
> variable may be unsafe. Consider using fopen_s instead. To disable  
> deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for det 
>  
> ails. 
>  
>          C:\Program Files (x86)\Microsoft Visual Studio  
> 10.0\VC\INCLUDE\stdio.h(234) : see declaration of 'fopen' 
>  
> ..\generate_uudmap.c(81) : warning C4996: 'strerror': This function or  
> variable may be unsafe. Consider using strerror_s instead. To disable  
> deprecation, use _CRT_SECURE_NO_WARNINGS. See online help f 
>  
> or details. 
>  
>          C:\Program Files (x86)\Microsoft Visual Studio  
> 10.0\VC\INCLUDE\string.h(157) : see declaration of 'strerror' 
>  
> ..\generate_uudmap.c(91) : warning C4996: 'strerror': This function or  
> variable may be unsafe. Consider using strerror_s instead. To disable  
> deprecation, use _CRT_SECURE_NO_WARNINGS. See online help f 
>  
> or details. 
>  
>          C:\Program Files (x86)\Microsoft Visual Studio  
> 10.0\VC\INCLUDE\string.h(157) : see declaration of 'strerror' 
>  
>          link -subsystem:console -out:..\generate_uudmap.exe  
> @C:\Users\huangm4\AppData\Local\Temp\nm6F1E.tmp 
>  
> LINK : fatal error LNK1181: cannot open input file 'bufferoverflowU.lib' 
>  
> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual  
> Studio 10.0\VC\bin\amd64\link.EXE"' : return code '0x49d' 
>  
> Stop. 
>  
>  
>  
> C:\Users\huangm4\Downloads\perl-5.17.3\win32> 
>  
>  
>  
> Sorry to bother you. Really appreciate your help. 
>  
>  
>  
> Thanks 
>  
> Mike 
>  
>  
>  
For your compiling perl attempt, you have to set the version number of your Microsoft compiler in the makefile. Read the first couple pages in the makefile. You went down the VC6 path in the makefile probably.

About your code, I ran the script under ActivePerl 5.10 and my VC DEBUGGING 5.17.3/4 and nothing abnormal happened (crashes/console errors).  I replaced invalid_command with dir, and still nothing abnormal happened. I then used the for loop thing (DOS batch files are not my specialty), on ActivePerl 5.10 I ctrl-ced it after 2 mins, no errors. On 5.17 I got a hang. Callstack for starting thread is
_______________________________________________________________

     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     kernel32.dll!_WaitForSingleObjectEx@12()  + 0x8b    
     kernel32.dll!_WaitForSingleObject@8()  + 0x12    
>    threads.dll!XS_threads_join(interpreter * my_perl=0x0038420c, cv * cv=0x009636ec)  Line 1247 + 0xf    C
     perl517.dll!Perl_pp_entersub(interpreter * my_perl=0x0038420c)  Line 2754 + 0x10    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x0038420c)  Line 2134 + 0xd    C
     perl517.dll!S_run_body(interpreter * my_perl=0x0038420c, long oldscope=0x00000001)  Line 2392 + 0xd    C
     perl517.dll!perl_run(interpreter * my_perl=0x0038420c)  Line 2309 + 0xd    C
     perl517.dll!RunPerl(int argc=0x00000002, char * * argv=0x00342cf0, char * * env=0x00346918)  Line 270 + 0x9    C++
     perl.exe!main(int argc=0x00000002, char * * argv=0x00342cf0, char * * env=0x003432b8)  Line 23 + 0x12    C
     perl.exe!mainCRTStartup()  Line 398 + 0xe    C
     kernel32.dll!_BaseProcessStart@4()  + 0x23    
________________________________________________________________
Threads list
_________________________________________________________________
     3796    main    XS_threads_join    Normal    0
>    162176    S_ithread_run    _lock    Normal    0
     5156    S_ithread_run    _lock    Normal    0
     6792    S_ithread_run    _lock    Normal    0
     7620    S_ithread_run    _lock    Normal    0
     166660    S_ithread_run    win32_popen    Normal    0
     5692    S_ithread_run    _alloc_osfhnd    Normal    0
     4728    S_ithread_run    _lock    Normal    0
     6280    S_ithread_run    _lock    Normal    0
     5616    S_ithread_run    _lock    Normal    0
     2304    S_ithread_run    _lock    Normal    0
_____________________________________________________________
next thread
_____________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x00aefc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x00aefc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x009c8fc4, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x00348278, const char * command=0x009c8fc4, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x009051d4)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x009051d4)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x009051d4, sv * sv=0x009bc7c4, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x0090306c)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
_____________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_dup_lk(int fh=0x00000001)  Line 104 + 0x5    C
     msvcr71.dll!_dup(int fh=0x00000001)  Line 74 + 0x6    C
     perl517.dll!win32_dup(int fd=0x00000001)  Line 3221 + 0xa    C
     perl517.dll!win32_popen(const char * command=0x0099237c, const char * mode=0x28239a24)  Line 2904 + 0x9    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x003489b8, const char * command=0x0099237c, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x00971024)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x00971024)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x00971024, sv * sv=0x00b0d60c, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x0099e31c)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
__________________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x00eefc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x00eefc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x00b37974, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x003490f8, const char * command=0x00b37974, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x00991454)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x00991454)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x00991454, sv * sv=0x00b6362c, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x00b19ca4)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x00fefc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x00fefc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x00b930fc, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x00349838, const char * command=0x00b930fc, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x009e20dc)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x009e20dc)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x009e20dc, sv * sv=0x00bb264c, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x00b6fd84)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
____________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    perl517.dll!win32_popen(const char * command=0x00c75a84, const char * mode=0x28239a24)  Line 2900    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x00349f78, const char * command=0x00c75a84, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x00b369bc)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x00b369bc)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x00b369bc, sv * sv=0x00c1854c, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x00bbedc4)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
_______________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_alloc_osfhnd()  Line 112    C
     msvcr71.dll!_pipe(int * phandles=0x011efc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x011efc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x01314144, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x0034a7e8, const char * command=0x01314144, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x00b85a44)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x00b85a44)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x00b85a44, sv * sv=0x00b1be74, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x00c24d44)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
_______________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x012efc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x012efc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x012f925c, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x0034b008, const char * command=0x012f925c, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x00c50014)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x00c50014)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x00c50014, sv * sv=0x00cc2b5c, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x00c4cf04)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
________________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x017efc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x017efc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x012f917c, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x0034b790, const char * command=0x012f917c, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x00ccf24c)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x00ccf24c)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x00ccf24c, sv * sv=0x0131188c, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x00cab07c)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
______________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x018efc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x018efc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x00c7a2f4, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x0034cdc0, const char * command=0x00c7a2f4, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x0133d5c4)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x0133d5c4)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x0133d5c4, sv * sv=0x01370e84, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x013260e4)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
_____________________________________________________________________
     ntdll.dll!_KiFastSystemCallRet@0()     
     ntdll.dll!_ZwWaitForSingleObject@12()  + 0xc    
     ntdll.dll!_RtlpWaitForCriticalSection@4()  + 0x8c    
     ntdll.dll!_RtlEnterCriticalSection@4()  + 0x46    
>    msvcr71.dll!_lock(int locknum=0x0000000b)  Line 319 + 0x8    C
     msvcr71.dll!_alloc_osfhnd()  Line 59 + 0x7    C
     msvcr71.dll!_pipe(int * phandles=0x019efc40, unsigned int psize=0x00000200, int textmode=0x00000080)  Line 87 + 0x5    C
     perl517.dll!win32_pipe(int * pfd=0x019efc40, unsigned int size=0x00000200, int mode=0x00000080)  Line 2834 + 0x12    C
     perl517.dll!win32_popen(const char * command=0x013831ac, const char * mode=0x28239a24)  Line 2894 + 0x12    C
     perl517.dll!PerlProcPopen(IPerlProc * piPerl=0x0034c448, const char * command=0x013831ac, const char * mode=0x28239a24)  Line 1621 + 0xd    C++
     perl517.dll!Perl_pp_backtick(interpreter * my_perl=0x0137d5bc)  Line 309 + 0x1e    C
     perl517.dll!Perl_runops_debug(interpreter * my_perl=0x0137d5bc)  Line 2134 + 0xd    C
     perl517.dll!Perl_call_sv(interpreter * my_perl=0x0137d5bc, sv * sv=0x013cfbac, volatile long flags=0x0000000a)  Line 2691 + 0x36    C
     threads.dll!S_ithread_run(void * arg=0x0135904c)  Line 517 + 0x1b    C
     kernel32.dll!_BaseThreadStart@8()  + 0x37    
_________________________________________________________________________


Since you have a copy of visual studio, download the symbol files for your ActivePerl from http://downloads.activestate.com/ActivePerl/releases/5.16.0.1600/, extract the pdb files so all of them are right next to the DLLs and exes they represent. Then do File-Open-Project, goto perl/bin and select perl.exe as the "project" (we aren't compiling perl using the IDE).

I have to go, but from staring at the callstacks for about a minute, my guess right now is somehow the opcode critical section is deadlocking against the CRT's handle allocator CS. My plan is to look inside the CS structs and see who the owner TIDs are of the CSes.

Anyone else who sees or thinks something on P5P is welcome to join in.
 		 	   		  
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About