bug-bash
[Top][All Lists]
Advanced

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

Re: Infinite loop triggered by extglob +(!(x))y


From: Andreas Schwab
Subject: Re: Infinite loop triggered by extglob +(!(x))y
Date: Sun, 25 Jul 2021 19:50:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

On Jul 25 2021, Greg Wooledge wrote:

> On Sun, Jul 25, 2021 at 07:09:50PM +0200, andrej--- via Bug reports for the 
> GNU Bourne Again SHell wrote:
>> Description:
>>      An extglob like +(!(x))y causes Bash to freeze with a 100% CPU 
>> utilization.
>>      At the first glance the freeze doesn't seem to depend on the 
>> (non-)existence of matching paths.
>
> The files do seem to matter.
>
> unicorn:~/tmp$ echo +(!(x))y
> servers-to-try
> unicorn:~/tmp$ cd /tmp
> unicorn:/tmp$ echo +(!(x))y
> ^C^C^ZKilled

It depends on the length of the existing file names.  That pattern has
quadratic complexity.

> It's a really bad runaway, requiring SIGKILL from another terminal to
> stop it.

Not really.  It's just that an interactive shell ignores or postpones a
lot of signals during command execution.  In a non-interactive shell, a
simple SIGINT will stop it.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



reply via email to

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