[Top][All Lists]

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

Re: Bash bind bug: infinite loop with memory leak in Readline

From: Chet Ramey
Subject: Re: Bash bind bug: infinite loop with memory leak in Readline
Date: Sun, 18 Sep 2016 21:41:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 8/10/16 11:42 AM, Christian Klomp wrote:
> Hi,
> I found a problem with the binding of key sequences to macros that
> results in bash allocating all the memory until the process is killed.
> It happens when a key is mapped to itself, e.g., `bind '"3":"3"'`. Now
> when '3' is typed the while loop inside the readline_internal_charloop
> function will never end.

Yes, you've triggered an infinite loop with the key binding.  One of the
strengths of macros is that the expansion is not simply a string -- it can
be used as shorthand for a complex key sequence, so simply disallowing
the general case is not really an option.  I don't think anyone is going
to deliberately bind a key to itself, so I'm not sure putting code in to
solve that specific case, while leaving the general case unsolved, is

Maybe the thing to do is to abort at some maximum macro nesting level, sort
of like bash does with $FUNCNEST.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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