GNU bug report logs - #13472
Execution mode can hang pc when parameter refers to big file

Previous Next

Package: libtool;

Reported by: Pavel Raiskup <praiskup <at> redhat.com>

Date: Thu, 17 Jan 2013 11:11:02 UTC

Severity: normal

Done: Peter Rosin <peda <at> lysator.liu.se>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Pavel Raiskup <praiskup <at> redhat.com>
To: bug-libtool <at> gnu.org
Subject: 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:

  http://bugzilla.redhat.com/636045

=====

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.

Pavel









This bug report was last modified 11 years and 23 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.