[Top][All Lists]

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

memory leak in read builtin

From: Lars Ellenberg
Subject: memory leak in read builtin
Date: Tue, 6 Nov 2007 23:53:02 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
uname output: Linux johann 2.6.18-5-686 #1 SMP Wed Sep 26 17:54:59 UTC 2007 
i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

(debian etch, bash 3.1dfsg-8)

        aparently I hit a memory leak in the read builtin.

        yes | bash -c 'ulimit -v 1000; while read a ; do :; done'

        bash: xmalloc: ../bash/make_cmd.c:99: cannot allocate 2 bytes (0 bytes 

        note that
                yes | while read; do :; done
                yes | while read a b ; do :; done
        both run "forever".

        this apears to be only triggered
        when the number of input fields is larger
        than the number of variables.
        I did not check too closely yet,
        nor did I build a debug version or run it through gdb.

        But from looking at the code,
        I suspect that in builtins/read.def:647 ...
        the allocated temporary space for t is never FREE'd.

        |  /* Check whether or not the number of fields is exactly the same as 
        |     number of variables. */
        |  if (*input_string)
        |    {
        |      t1 = input_string;
        |      t = get_word_from_string (&input_string, ifs_chars, &e); <<<<====
        |      if (*input_string == 0)
        |       input_string = t;
        |      else
        |       input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, 
        |    }

thanks for listening,
awaiting your feedback.

        Lars Ellenberg

: Lars Ellenberg                            Tel +43-1-8178292-55 :
: LINBIT Information Technologies GmbH      Fax +43-1-8178292-82 :
: Vivenotgasse 48, A-1120 Vienna/Europe    http://www.linbit.com :

reply via email to

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