1.7.7: wrapped sh.exe 100% cpu core usage and unexpected process behaviour

Vasek Prochazka trexatrix@seznam.cz
Fri Dec 17 03:09:00 GMT 2010


Hi folks,
I have run into situation where sh.exe process consumes whole cpu core and make does not proceeds further. I observed this behavior on two unrelated cpu intense makefiles, but don really see a common cause. The second one even works as expected when ran with -j1 but hangs with -j2. 
This might be same issue as http://cygwin.com/ml/cygwin/2010-11/msg00080.html , but I'm not sure, I was not able to attach gdb to it. (More on that later.) Attached cygcheck -svr is from snapshot 20101215, but I originally run into this issue also on 1.7.7.

I was able to reproduce the problem only on that particular pc (Win XP SP3), tried to reproduce it on few other PC's (XP SP2 &SP3, all clean 1.7.7; default packages) but test script finished as expected. It also might be a BLODA, I have installed outpost firewall (on list) and avast (not on list, but other AV are there..). I tried to deactivate them but no change, I didn't try to completely uninstall them yet. On one of the XPSP3 PC's, where it didn't hang they are installed too, but lower versions. Clean Cygwin reinstall didn't help.

There is following simple testcase on which I'm able to reproduce it hang-test.sh:
hang-test.sh
#!/bin/bash

for i in {1..3}
do
  echo "hangtest-$i" | gzip -c > hang-test-in.gz
  gunzip -f < hang-test-in.gz >hang-test-out
  #gzip -df < hang-test-in.gz >hang-test-out
done

For the sake of completeness 
cat /bin/gunzip
#!/bin/sh
PATH=${GZIP_BINDIR-'/usr/bin'}:$PATH
exec gzip -d "$@"
 
Testcase I run as:

$./hang-test.sh 2>err

- expected result: file hang-test-out containing string "hangtest-$i" (without quotes) where $i is number last for loop iteration
- actual result: script hangs with sh.exe consuming one cpu core
- without error output redirection works as expected
- when I "unwrap" the gunzip script and use the commented gzip line, works as expected
- for only one for loop iteration works as expected
- hangs in second iteration, when problematic sh.exe killed (using windows task manager) gives expected result, but hangs again in third iteration
- when killed in third (last) iteration gives expected result but whole cygwin console also closes

Now some unexpected process behavior (or I'm missing something...):
Process Exporer (sysinternals): 
PID: 3588
commandline: C:\cygwin\bin\sh.exe /usr/bin/gunzip -f


$ ps -Wla | grep 3588
 [nothing]

There isn't such process with this windows id?!]
$ ps -Wla | grep -v '?'
     PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
     268       1     268        268  con  500 23:24:51 /c/CygWin/bin/bash
    3484       1    3484       3484  con  500 00:15:32 /c/CygWin/bin/bash
    2376    3484    2376       3636  con  500 00:15:48 /usr/bin/bash
    3796    2376    2376       3660  con  500 00:15:49 /usr/bin/gzip
    3664       0       0       3664    0  500 00:17:29 C:\CygWin\bin\bash.exe
    1220     268    1220       3516  con  500 00:17:29 /usr/bin/ps

since gzip seem to be involved lets try kill it:

$ kill 3796
bash: kill: (3796) - No such process

Seem to me like sh.exe process hanged somewhere in the very end of its lifecycle.
Also when I try to attach gdb to the sh.exe process, gdb gets stuck. I'm able to attach it to some other process.

$ gdb
GNU gdb 6.8.0.20080328-cvs (cygwin-special)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
(gdb) attach 3588
Attaching to process 3588
[New thread 3588.0xd68]
[New thread 3588.0x7f0]

... and hangs there, no prompt. Prompt appears only after I kill the sh.exe process.

In this case I can go around it by unwrapping the gunzip script, but in the other makefile there is not any script to unwrap on that particular line.

I'll be thankful for any help or suggestions, but since I was not able to reproduce it on any other PC, this might be a difficult one. 
I'll try to uninstall both FW and AV, but that don't really solves my issue, more like just confirms it is BLODA, and get use to it.

Thanks 

Vaclav

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: text/x-news charset=utf-8
Size: 28140 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20101217/f5e17f4d/attachment.bin>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list