A tale of "../libtool: fork: Resource temporarily unavailable" issue.

Ravi V ravi_sparks@yahoo.com
Tue Oct 31 22:09:00 GMT 2006


A tale of "../libtool: fork: Resource temporarily 
unavailable" issue (cygcheck output attached).

Problem
-------
Builds using cygwin shell (sh) fail with "../libtool:
fork: Resource temporarily unavailable" error. This 
happens when building mysql, for example. The "fork: 
Resource temporarily unavailable" can appear for a 
variety of reasons.

Signature of failure
--------------------
Here is how the error looks in the  mysql build 
which uses a shell script called "libtool":

----------------------------------------------------------------
/bin/sh ../libtool \--mode=compile gcc 

\-DDEFAULT_CHARSET_HOME="\"/usr/local\""
; \-DDATADIR="\"/usr/local/var\"" \-DSHAREDIR="\"/u
sr/local/share/mysql\"" \-DUNDEF_THREADS_HACK
\-DDONT_USE_RAID  

\-I./../include \-I.
./include \-I./.. \-I.. \-I.. \-O3 \-DDBUG_OFF \-c
strmov.c
../libtool: fork: Resource temporarily unavailable
libtool: compile: cannot determine name of library
object from `'
make\[2\]: \**\* \[strmov.lo\] Error 1
make\[2\]: Leaving directory
`e:/src/mysql-5.0.18/obj/libmysql'
make\[1\]: \**\* \[all-recursive\] Error 2
make\[1\]: Leaving directory `e:/src/mysql-5.0.18/obj'
make: \**\* \[all-recursive-am\] Error 2
----------------------------------------------------------------

Triage/Isolation
-----------------
Isolation of this issue revealed that this message
typically comes from the occassional failure of 
Cygwin shell in properly handling a sub-shell which 
uses a pipe.

The source of the build failure is the "Resource 
temporarily unavailable" problem probably has its root

in some bugs in Cygwin which cause it to not properly 
handle a sub-shell (invoked with backquote shell 
feature) and where the subshell uses a pipe. Here is a

simple example:

temp_lastarg=`$echo "X$lastarg" \| $Xsed \-e
"$sed_quote_subst"`

Problem reproduction:
--------------------
This problem happens readily on dual-cores. It may 
happen on single-core  machines but probably less 
readily.

Launch 3 to 5 cygwin windows (at least 3 of them are 
needed to reproduce the issue. I couldn't reproduce 
with just 2).

Create a testSh.sh file and add the following commands

to it:
-------------------------------------------------------

#!/bin/sh

lastarg=-DUNDEF_THREADS_HACK
sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'

while [ -f testSh.sh ];
do
        lastarg=`$echo "X$lastarg" | $Xsed -e
"$sed_quote_subst" | $Xsed -e "$sed_quote_subst" |
$Xsed -e "$sed_quote_subst"`
done
-------------------------------------------------------

Run the following command in each of them:
-------------------------------------------------------
script sh -x testSh.sh
-------------------------------------------------------

fork problem will appear fairly quickly (within
minutes).

Workaround
----------
The solution is to rewrite the source script such that

the susceptible command is reissued. Here is an 
example of how the problem case above can be fixed. 

-------------------------------------------------------temp_lastarg=
temp_lastarg=`$echo "X$lastarg" | $Xsed -e
"$sed_quote_subst"`
if test -n "$lastarg" && test -z "$temp_lastarg"; then
    # Retry the last command.
    temp_lastarg=`$echo "X$lastarg" | $Xsed -e
"$sed_quote_subst"`
fi
lastarg=$temp_lastarg
-------------------------------------------------------

<End of message>



 
____________________________________________________________________________________
Want to start your own business? Learn how on Yahoo! Small Business 
(http://smallbusiness.yahoo.com) 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck_s_v_r.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20061031/3e1ed937/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