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

 
 

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

Submitted by:  tigrmesh <tigrmesh>
Submitted on:  Wed Jul 8 02:01:02 2009  
 
Severity: 2 - MinorStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sat Jan 9 19:40:53 2016, 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>
Project AdministratorIn charge of this item.
Sun Jul 19 11:11:03 2015, 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>
Project AdministratorIn charge of this item.
Sat Feb 22 20:08:56 2014, 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>
Project AdministratorIn charge of this item.
Wed Sep 18 09:57:33 2013, 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>
Project AdministratorIn charge of this item.
Tue Sep 17 19:08:20 2013, 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 Sep 17 18:43:16 2013, 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 Sep 17 18:32:42 2013, comment #3:

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

tigrmesh <tigrmesh>
Sat Sep 14 08:37:30 2013, 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>
Project AdministratorIn charge of this item.
Thu Jul 23 05:31:17 2009, 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 Jul 8 02:01:02 2009, 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.)

Attach File(s):
   
   
Comment:
   

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
  • -unavailable- added by bens (Posted a comment)
  • -unavailable- added by tigrmesh (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Jan 14 16:37:47 2016bensOpen/ClosedOpen=>Closed
    Sat Jan 9 19:40:53 2016bensAttached File-=>Added skip-zero-length-matches.patch, #35956
      StatusNeed Info=>Fixed
    Sun Jul 19 11:11:03 2015bensSeverity3 - Normal=>2 - Minor
      Summarynano 2.1.9 freezes with PKGBUILD syntax highlighting=>a multiline regex with only anchors makes nano hang
    Sat Feb 22 20:08:56 2014bensStatusNone=>Need Info
      Assigned toNone=>bens
      SummaryPossible memory leak with nano 2.1.9 syntax highlighting=>nano 2.1.9 freezes with PKGBUILD syntax highlighting
    Wed Sep 18 09:57:33 2013bensAttached File-=>Added stop-hanging-and-DO-colour.patch, #29172
    Wed Jul 8 02:01:03 2009tigrmeshAttached File-=>Added pkgbuild.nanorc, #18381
    Wed Jul 8 02:01:02 2009tigrmeshAttached File-=>Added PKGBUILD, #18380

    Back to the top


    Powered by Savane 3.1-cleanup