[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13472: Execution mode can hang pc when parameter refers to big file

From: Pavel Raiskup
Subject: bug#13472: Execution mode can hang pc when parameter refers to big file
Date: Thu, 17 Jan 2013 12:09:44 +0100

Hi liboolers,

the problem — e.g. running the:

  libtool execute ls BIGfile

could stack computer atm (if user has swap enabled and) if the BIGfile
refers to really big file not containing new-lines.

For more info see the bug:



The problem is that libtool is trying to guess whether the 'BIGfile' is
ltwrapper or not (I guess).  One step in this check is that libtool runs
sed for 'head' purposes:

  sed -e 4q BIGfile

The problem of this sed command is that it is probably buffering whole
"binary lines" (which may have gigabytes) into memory.  Don't know "how"
it is doing there, but 'head' utility hes _smaller_ space complexity (two
runs?).  Unfortunately, both sed & head could go through whole really big
file and it can take too long (+ sed costs too much memory).

If you see the Comment #7 in referenced bug, Paolo suggest to use 'dd'
utility.  It would be easy to use dd as sed's "limiter":

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index c8cdb9c..a92b3bb 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -575,7 +575,7 @@ _LTECHO_EOF'
 func_lalib_p ()
     test -f "$1" &&
-      $SED -e 4q "$1" 2>/dev/null \
+      dd if="$1" bs=16K count=1 2>/dev/null | $SED -e 4q 2>/dev/null \
         | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1

Using sed as the head utility is quite common in libtool project, probably
it would be fine to generalize head task that (or other) way.  I am able
to prepare patch if you are interested.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]