bugGNU nano - Bugs: bug #26977, a multiline regex with only...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #26977: a multiline regex with only anchors makes nano hang

Submitter:  tigrmesh <tigrmesh>
Submitted:  Wed 08 Jul 2009 02:01:02 AM UTC
   
 
Severity:  2 - Minor Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Jump to the original submission

Sat 09 Jan 2016 07:40:53 PM UTC, comment #9: 

Fixed in SVN, r5538.

(The applied patch is fully different from the one posted before.  See the new attachment.)

(file #35956)

Benno Schulenberg <bens>
Group administrator
Sun 19 Jul 2015 11:11:03 AM UTC, comment #8: 

The basic problem is triggered when having a line like the following included in a syntax definition:

color red "^" "$"

The patch will fix this.  But maybe nano should simply discard this absolute border case?  As it should have been written as:

color red "^.*$"

Benno Schulenberg <bens>
Group administrator
Sat 22 Feb 2014 08:08:56 PM UTC, comment #7: 

Could you try the patch (building nano from source) and report whether it then works for you with the complicated syntax?

Benno Schulenberg <bens>
Group administrator
Wed 18 Sep 2013 09:57:33 AM UTC, comment #6: 

Attached patch fixes the problem for me.  If you could try it, that would be nice.  (It is just a temporary repair -- if it is the fully correct fix, then a pair of braces can be removed and a whole lot of text unindented.)

What remains, however, is that your original regexp is an absolute corner case, and kind of strange: it uses the multi-line matching syntax when all it wants to do is colour every line green.  This one can also do with the single-line syntax I proposed: "^.*$".

Your multi-line variant is strange also in a second way: it doesn't actually match any characters.  As soon it does, for example by adding a period after the ^ or before the $, also the unpatched nano does not hang any more.  Using « color green start="^." end="$" » works fine here, patched and unpatched; the variant « color green start="^" end=".$" », however, does not colour everyhting green in the unpatched nano, but works fine in the patched version, just like your original very hungry regexp.

(file #29172)

Benno Schulenberg <bens>
Group administrator
Tue 17 Sep 2013 07:08:20 PM UTC, comment #5: 

As I look again, I think this bug (bug #26977) is a duplicate of bug #29014: Failure to open when editing certain files named as PKGBUILD

tigrmesh <tigrmesh>
Tue 17 Sep 2013 06:43:16 PM UTC, comment #4: 

I think this bug (#26977) and bug #29014 are related.

bug #29014: Failure to open when editing certain files named as PKGBUILD
https://savannah.gnu.org/bugs/?29014

tigrmesh <tigrmesh>
Tue 17 Sep 2013 06:32:42 PM UTC, comment #3: 

I removed the problem line and added the line you had suggested.  This works wonderfully.  Thank you.

tigrmesh <tigrmesh>
Sat 14 Sep 2013 08:37:30 AM UTC, comment #2: 

The first time I tried this on your files, with debugging enabled, I got "match found at pos 70... end found on this line" rolling on and on over the screen.  Subsequent runs, however, hung silently.

But why use the syntax «color green start="^" end="$"» to colour everything at first?  When reworded as «color green "^.*$"», the colouring works fine.

Benno Schulenberg <bens>
Group administrator
Thu 23 Jul 2009 05:31:17 AM UTC, comment #1: 

After having conferred with Those Who Know More, it has been determined that the title of this bug is misleading.  It should read:  "nano 2.1.9 freezes with PKGBUILD syntax highlighting".

Also, it has been discovered that if you comment out the first color line (green) in the nanorc, it works.  I was unable to find any information on how to do syntax highlighting in nano.  Maybe the end syntax has changed.  Please let me know.  Thanks.

tigrmesh <tigrmesh>
Wed 08 Jul 2009 02:01:02 AM UTC, original submission:  

Using nano 2.1.9, trying to open a PKGBUILD* with syntax highlighting, nano uses between 88 and 94 percent of my CPU.  No file ever opens, and I have a completely blank terminal.

Perl, python and bash syntax files all open fine with syntax highlighting in 2.1.9.

2.0.9 used this syntax highlighting with no problems.

I have attached the pkgbuild.nanorc and a PKGBUILD for you to test.



*A PKGBUILD is an Arch Linux package making script.

tigrmesh <tigrmesh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #29172:  stop-hanging-and-DO-colour.patch added by bens (837B - text/x-patch - stops nano from hanging on an anchors-only regexp, and does colour it)
file #18381:  pkgbuild.nanorc added by tigrmesh (826B - application/octet-stream - pkgbuild.nanorc and a PKGBUILD)
file #18380:  PKGBUILD added by tigrmesh (856B - application/octet-stream - pkgbuild.nanorc and a PKGBUILD)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by tigrmesh (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-01-14 bens Open/ClosedOpen Closed
    2016-01-09 bens Attached File- Added skip-zero-length-matches.patch, #35956
        StatusNeed Info Fixed
    2015-07-19 bens Severity3 - Normal 2 - Minor
        Summarynano 2.1.9 freezes with PKGBUILD syntax highlighting a multiline regex with only anchors makes nano hang
    2014-02-22 bens StatusNone Need Info
        Assigned toNone bens
        SummaryPossible memory leak with nano 2.1.9 syntax highlighting nano 2.1.9 freezes with PKGBUILD syntax highlighting
    2013-09-18 bens Attached File- Added stop-hanging-and-DO-colour.patch, #29172
    2009-07-08 tigrmesh Attached File- Added pkgbuild.nanorc, #18381
    2009-07-08 tigrmesh Attached File- Added PKGBUILD, #18380

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code