buggrep - Bugs: bug #36842, grep -P dumps when using large...

 
 

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

bug #36842: grep -P dumps when using large regex, version 2.5.1

Submitter:  Robert Klima <robertklima>
Submitted:  Fri 13 Jul 2012 03:39:03 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Fri 13 Jul 2012 03:39:03 PM UTC, original submission:  

This causes grep to dump:

klr@vwglnx02:~> ( echo 'if ( GetProfileStr( "GLOBAL", "HW", ins, iVar->hw,
sizeof( iVar->hw ) - 1,'; echo '               pcx->iniFile )) x=2;  /* return
value not used */' ) | grep -P
'(?s)if\s*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()](?#innerpart)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)]\s*((?#a_comment)\s*[/][*]([^*]|[*][^/])*[*][/]\s*)*;'
Aborted (core dumped)

remove these three chars "x=2" and it works:

klr@vwglnx02:~> ( echo 'if ( GetProfileStr( "GLOBAL", "HW", ins, iVar->hw,
sizeof( iVar->hw ) - 1,'; echo '               pcx->iniFile )) ;  /* return
value not used */' ) | grep -P
'(?s)if\s*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()](?#innerpart)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)]\s*((?#a_comment)\s*[/][*]([^*]|[*][^/])*[*][/]\s*)*;'
if ( GetProfileStr( "GLOBAL", "HW", ins, iVar->hw, sizeof( iVar->hw ) - 1,
               pcx->iniFile )) ;  /* return value not used */

klr@vwglnx02:~> grep --version
grep (GNU grep) 2.5.1

Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Explanation of the regex:
The regex is a straight forward aproach to check for balanced parantheses in
C-code and then to check whether there is an if-statement or not (empty
if-statement).
It is necessary to code such a complex regex like this as regex normally cannot
be used to deal with balanced parantheses.

It even happens here:

klr@vwglnx02:~> ( echo 'if ( GetProfileStr( "GLOBAL", "HW", ins, iVar->hw,
sizeof( iVar->hw ) - 1,'; echo '               pcx->iniFile )) x=2;  /* return
value not used */' ) | grep -P
'(?s)if\s*[(][^()]*([^()]*[(][^()]*([^()]*[(][^()]*(?#innerpart)[^()]*[)][^()]*)*[^()]*[)][^()]*)*[^()]*[)];'
Aborted (core dumped)

Robert Klima, Dev. Manager, UC4 Software Inc.

Robert Klima <robertklima>

 

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

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by robertklima (Submitted the item)
  • -email is unavailable- added by robertklima
  •  

    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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-07-13 robertklima Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code