1.5.5-1 command substitution hangs (0% cpu) on XP

Antoine Labour antoine.labour@m4x.org
Thu Nov 20 03:32:00 GMT 2003


Hi Geoff, Guys,

I'm having a similar problem, on two different computers, one XP (Xeon 
with HT), one 2k (single processor).
I did a windows update last friday (nov 14th), about the time the 
problems appeared. I also updated cygwin to the latest release at the 
same time (unforunately...).
On the XP machine, I pulled the cvs version of cygwin, compiled it, 
installed it, and the problem persists. I tried the updated version of 
bash (<ftp://sourceware.org/pub/cygwin/tmp/bash.exe>), still the same.

The exact behaviour is the following :
- I wrote this simple script that stress-tests command substitution :
#!/bin/bash
i=0
while true
do
	A=$(basename /bin/sh)
	i=$(($i+1))
	echo $i;
done

- I run it, and after some iterations (I got 5 once, more than 500 
another time) it hangs. Once it crashed (segv). When it hangs, there are 
two running bash processes (suposedly the one for the script and the one 
for running the command). I cannot kill the child process (ctrl-c has no 
effect, kill on the child does nothing), but I can kill the parent.

- I tried attaching gdb to either process, here are the stack(s) dumps:

Child process (bash):
(gdb) info threads
* 3 thread 2564.0x404  0x77f75a59 in ntdll!DbgUiConnectToDbg ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
   2 thread 2564.0xac4  0x7ffe0304 in ?? ()
   1 thread 2564.0x59c  0x7ffe0304 in ?? ()
(gdb) thread 1
[Switching to thread 1 (thread 2564.0x59c)]#0  0x7ffe0304 in ?? ()
(gdb) bt
#0  0x7ffe0304 in ?? ()
#1  0x77f5b5d4 in ntdll!ZwClose () from 
/cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x77e7a730 in KERNEL32!CloseHandle ()
    from /cygdrive/c/WINDOWS/system32/KERNEL32.DLL
#3  0x00000680 in ?? ()
#4  0x6106bb0a in fhandler_pipe::close() (this=0x6167175c)
     at /home/piman/cygwin/src/winsup/cygwin/pipe.cc:96
#5  0x6108f186 in close (fd=3)
     at /home/piman/cygwin/src/winsup/cygwin/cygheap.h:289
#6  0x00425921 in command_substitute (string=0xa0452e0 "basename /bin/sh",
     quoted=0) at /netrel/src/bash-2.05b-1/subst.c:3812
#7  0x0042815e in param_expand (string=0xa044c50 "$(basename /bin/sh)",
     sindex=0x22fa64, quoted=0, expanded_something=0x0,
     contains_dollar_at=0x22fa68, quoted_dollar_at_p=0x22fa6c,
     had_quoted_null_p=0x22fa70, pflags=0)
     at /netrel/src/bash-2.05b-1/subst.c:5361
#8  0x00428755 in expand_word_internal (word=0x22fad8, quoted=0, isexp=0,
     contains_dollar_at=0x0, expanded_something=0x0)
     at /netrel/src/bash-2.05b-1/subst.c:5626
#9  0x00423d70 in call_expand_word_internal (w=0x22fad8, q=0, i=0, c=0x0,
     e=0x0) at /netrel/src/bash-2.05b-1/subst.c:2312
#10 0x00423e31 in expand_string_internal (
     string=0xa044c38 "$(basename /bin/sh)", quoted=0)
     at /netrel/src/bash-2.05b-1/subst.c:2345
#11 0x00423e89 in expand_string_unsplit (
     string=0xa044c38 "$(basename /bin/sh)", quoted=0)
     at /netrel/src/bash-2.05b-1/subst.c:2367
#12 0x00423ad0 in expand_string_if_necessary (
     string=0xa044c38 "$(basename /bin/sh)", quoted=0,
     func=0x423e50 <expand_string_unsplit>)
     at /netrel/src/bash-2.05b-1/subst.c:2176
#13 0x0042367b in do_assignment_internal (
     string=0xa044f28 "A=$(basename /bin/sh)", expand=1)
     at /netrel/src/bash-2.05b-1/subst.c:1949
#14 0x00423719 in do_assignment (string=0xa044f28 "A=$(basename /bin/sh)")
     at /netrel/src/bash-2.05b-1/subst.c:2007
#15 0x00429954 in expand_word_list_internal (list=0x22fba8, eflags=-1)
     at /netrel/src/bash-2.05b-1/subst.c:6659
(gdb) thread 2
[Switching to thread 2 (thread 2564.0xac4)]#0  0x7ffe0304 in ?? ()
(gdb) bt
#0  0x7ffe0304 in ?? ()
#1  0x77f5bfb4 in ntdll!ZwReadFile ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x77e7abbd in ReadFile () from /cygdrive/c/WINDOWS/system32/KERNEL32.DLL
#3  0x00000740 in ?? ()
(gdb) thread 3
[Switching to thread 3 (thread 2564.0x404)]#0  0x77f75a59 in 
ntdll!DbgUiConnectToDbg () from /cygdrive/c/WINDOWS/System32/ntdll.dll
(gdb) bt
#0  0x77f75a59 in ntdll!DbgUiConnectToDbg ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#1  0x77f5f31f in ntdll!KiUserCallbackDispatcher ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x00000005 in ?? ()
#3  0x00000004 in ?? ()
#4  0x00000001 in ?? ()
#5  0x003fffd0 in ?? ()
#6  0x8528a020 in ?? ()
#7  0xffffffff in ?? ()
#8  0x77fa88f0 in wcstombs () from /cygdrive/c/WINDOWS/System32/ntdll.dll



Parent process (bash):
(gdb) info threads
* 5 thread 3196.0xbec  0x77f75a59 in ntdll!DbgUiConnectToDbg ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
   4 thread 3196.0x814  0x7ffe0304 in ?? ()
   3 thread 3196.0xf1c  0x7ffe0304 in ?? ()
   2 thread 3196.0xad8  0x7ffe0304 in ?? ()
   1 thread 3196.0x894  0x7ffe0304 in ?? ()
(gdb) thread 1
[Switching to thread 1 (thread 3196.0x894)]#0  0x7ffe0304 in ?? ()
(gdb) bt
#0  0x7ffe0304 in ?? ()
#1  0x77f5c524 in ntdll!ZwWaitForMultipleObjects ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x77e75ee0 in WaitForMultipleObjectsEx ()
    from /cygdrive/c/WINDOWS/system32/KERNEL32.DLL
#3  0x00000002 in ?? ()
#4  0x0022f76c in ?? ()
#5  0x00000001 in ?? ()
(gdb) thread 2
[Switching to thread 2 (thread 3196.0xad8)]#0  0x7ffe0304 in ?? ()
(gdb) bt
#0  0x7ffe0304 in ?? ()
#1  0x77f5bfb4 in ntdll!ZwReadFile ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x77e7abbd in ReadFile () from /cygdrive/c/WINDOWS/system32/KERNEL32.DLL
#3  0x00000760 in ?? ()
(gdb) thread 3
[Switching to thread 3 (thread 3196.0xf1c)]#0  0x7ffe0304 in ?? ()
(gdb) bt
#0  0x7ffe0304 in ?? ()
#1  0x77f5c524 in ntdll!ZwWaitForMultipleObjects ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x77e75ee0 in WaitForMultipleObjectsEx ()
    from /cygdrive/c/WINDOWS/system32/KERNEL32.DLL
#3  0x00000002 in ?? ()
#4  0x00fdfe88 in ?? ()
#5  0x00000001 in ?? ()
(gdb) thread 4
[Switching to thread 4 (thread 3196.0x814)]#0  0x7ffe0304 in ?? ()
(gdb) bt
#0  0x7ffe0304 in ?? ()
#1  0x77f5bfb4 in ntdll!ZwReadFile ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x77e7abbd in ReadFile () from /cygdrive/c/WINDOWS/system32/KERNEL32.DLL
#3  0x00000680 in ?? ()
(gdb) thread 5
[Switching to thread 5 (thread 3196.0xbec)]#0  0x77f75a59 in 
ntdll!DbgUiConnectToDbg () from /cygdrive/c/WINDOWS/System32/ntdll.dll
(gdb) bt
#0  0x77f75a59 in ntdll!DbgUiConnectToDbg ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#1  0x77f5f31f in ntdll!KiUserCallbackDispatcher ()
    from /cygdrive/c/WINDOWS/System32/ntdll.dll
#2  0x00000005 in ?? ()
#3  0x00000004 in ?? ()
#4  0x00000001 in ?? ()
#5  0x011fffd0 in ?? ()
#6  0x852a5440 in ?? ()
#7  0xffffffff in ?? ()
#8  0x77fa88f0 in wcstombs () from /cygdrive/c/WINDOWS/System32/ntdll.dll




Please note that the process that has the "command_substitute" trace is 
indeed the child process (no mistake here), so that means the deadlock 
occurs before the actual exec. I'm totally new to the cygwin codebase, 
so I'm sorry I can't be any more helpful right now (although I'm willing 
to spend some time debugging it). Any insight would be appreciated.

I attached my 'cygcheck -srv' dump.

Thanks,
Antoine Labour

>> -----Original Message-----
>> From: Geoffrey Ruscoe [mailto:gruscoe@ARCcorp.com] 
>> Sent: Thursday, November 13, 2003 2:03 PM
>> To: 'cygwin@cygwin.com'
>> Subject: RE: 1.5.5-1 command substitution hangs (0% cpu) on XP
>> 
>> 
>> I'm sorry I posted this problem a second time (under this new 
>> name) ... I thought my first attempt was too shotty and was 
>> probably misnamed.  I was trying to continue the discussion 
>> that I had found that most closely matched (blah, blah).
> 
> 
> I don't think I've been forgiven yet ;)
> 
> 
>> So I thought about trying an older version of cygwin to see 
>> if that would cure what ails (should be ale's as in free beer 
>> in my case) me, but I couldn't find snap shots of an older 
>> release (maybe 1.3.22-1).  Is there a way to get this or 
>> would this not be helpful.
> 
> 
> I guess this is not a good idea
> 
> 
>> Really, if anybody has any hints or things for me to try it 
>> would be very greatly appreciated.  It seems so strange that 
>> I would be the only one having this problem even after the 
>> new version of bash.
> 
> 
> Either this is a real stumper, or is so simple that ~anyone~ [read: I]
> should have already figured it out, or ... What I would guess is that even
> though I searched and searched, read the faq, read the user guide, and read
> the posting guidelines I have offended all you hard working people -- and
> thus haven't deserved response.  I'm sure I deserve such retribution, I'm
> just not sure why ;).  To quote a famous bear: Oh bother.
> 
> Either way, keep up the good work, I have enjoyed using cygwin on many other
> occasions (when I have been forced to use m$ winbloz).
> 
> 
> Cheers
> 
> 
>> Thanks again,
>> Geoff
>> 
>> > -----Original Message-----
>> > From: Geoffrey Ruscoe [mailto:gruscoe@ARCcorp.com]
>> > Sent: Wednesday, November 12, 2003 11:12 AM
>> > To: 'cygwin@cygwin.com'
>> > Subject: 1.5.5-1 command substitution hangs (0% cpu) on XP
>> > 
>> > 
>> > I have seen a number of references to this problem, but none
>> > of the fixes seems to work.  I have used cygwin on many 
>> > systems and not had this problem.
>> > 
>> > Basically any form of command substitution hangs with 0% cpu
>> > usage.  Usually after a fresh reboot, the problem will not 
>> > occur for the first couple times I do it and then once the 
>> > first command substitution hangs, none of them work again 
>> > until a reboot.
>> > 
>> > Simple commands such as
>> > Echo `echo hi`
>> > Or
>> > echo `date`
>> > Or 
>> > The same using $(date), etc.
>> > 
>> > Have the same results as the post install scripts.
>> > 
>> > On this computer the setup has never completely worked always
>> > stopping on the post install scripts.
>> > 
>> > I can see the sh.exe processes in the task manager and have
>> > to kill them off.  As I do this the progress meter of setup 
>> > will continue until I have killed all of the locked sh 
>> > processes and the setup finally finishes.
>> > 
>> > I have tried
>> > * the recent version of bash that was offered here
>> > * giving everyone full rights to cygwin and the entire c drive.
>> > * setting USER and HOME
>> > * making sure there are no spaces in either
>> > * various settings for CYGWIN (thought I had it there after a 
>> > reboot). Now my CYGWIN is just: ntsec
>> > 
>> > here is my
>> > bash-2.05b$ uname -a
>> > CYGWIN_NT-5.1 Consultant01 1.5.5(0.94/3/2) 2003-09-20 16:31 
>> > i686 unknown unknown Cygwin
>> > 
>> > And my cygcheck -svr is attached.
>> > 
>> > The hang script hangs with both versions of bash (although
>> > not the first time or two after the fresh reboot).
>> > 
>> > I'm not sure what to try next.  If anyone can point me to a
>> > document that might help, or if you have any suggestions to 
>> > try or some more information I can provide, it would be 
>> > greatly appreciated.  And I apologize for having to ask for 
>> > help on what I am sure is a EBCAC.  I have never had this 
>> > problem before.  
>> > 
>> > Also important to note:  I think everything was working fine
>> > until the XP downloaded and installed some update it 
>> > "needed."  But it is too late to verify that.  I have deleted 
>> > cygwin and reinstalled it several times (including removing 
>> > the regedit entries.
>> > 
>> > Thanks again for anybody's help,
>> > 
>> > Geoff
>> > 
>> > 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck-dump
URL: <http://cygwin.com/pipermail/cygwin/attachments/20031120/c6ff5f32/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list