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: Chet Ramey
Subject: Re: Infinite loop triggered by extglob +(!(x))y
Date: Sun, 25 Jul 2021 16:51:03 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

On 7/25/21 1:09 PM, andrej--- via Bug reports for the GNU Bourne Again SHell wrote:

Bash Version: 5.1
Patch Level: 8
Release Status: release

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.

Repeat-By:
        echo +(!(x))y  # This freezes!

I can't reproduce this. This is a terribly inefficient pattern, and the
behavior is proportional to the number of files and length of filenames.
In the bash build directory, for instance, it fails right away, as it
should: there aren't any files ending in `y'. In /tmp, with fewer files
but longer filenames, it takes *much* longer.

I agree that interactive shells could be more responsive to SIGINT. It's
a question of checking for the flag the signal handler sets while
executing the pattern matcher itself, rather than solely in the upper
layers. This pattern spends a lot of time in a single call to strmatch(),
which matches a single filename against a pattern, and the current code
checks for SIGINT around calls to strmatch().

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



reply via email to

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