bug-grep
[Top][All Lists]
Advanced

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

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


From: Robert Klima
Subject: [bug #36842] grep -P dumps when using large regex, version 2.5.1
Date: Fri, 13 Jul 2012 15:39:04 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1

URL:
  <http://savannah.gnu.org/bugs/?36842>

                 Summary: grep -P dumps when using large regex, version 2.5.1
                 Project: grep
            Submitted by: robertklima
            Submitted on: Fr 13 Jul 2012 15:39:03 GMT
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

This causes grep to dump:

address@hidden:~> ( 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:

address@hidden:~> ( 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 */

address@hidden:~> 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:

address@hidden:~> ( 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.





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?36842>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

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