octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #45031] segfault with regexprep (large text, m


From: Carnë Draug
Subject: [Octave-bug-tracker] [bug #45031] segfault with regexprep (large text, many capturing groups)
Date: Tue, 05 May 2015 18:54:52 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.6.0

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

                 Summary: segfault with regexprep (large text, many capturing
groups)
                 Project: GNU Octave
            Submitted by: carandraug
            Submitted on: Tue 05 May 2015 18:54:51 GMT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Crash
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.0-rc4
        Operating System: GNU/Linux

    _______________________________________________________

Details:

The following was discovered by markuman on IRC. It causes Octave to segfault
but it's not exactly clear why. The attached file can be used for testing:


octave> file = "xlsread.m";
octave> fid = fopen (file);
octave> str = fread (fid, "char=>char").';
octave> fclose (fid);
octave> mainregex =
'((^|n)(([])}w.]''+|[^''%])+|''[^''n]*(''''[^''n]*)*'')*)[^n]*';
octave> str = regexprep (str, mainregex, "$1");
Segmentation fault


One way to prevent this is by turning the 4th group, into a non-capturing,
i.e,:


mainregex = "((^|n)((?:[])}w.]'+|[^'%])+|'[^'n]*(''[^'n]*)*')*)[^n]*";


but I think it should be possible to capture all groups. Trying with many
other files, the issue seems to be a function of both character number and
regexp complexity.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Tue 05 May 2015 18:54:51 GMT  Name: xlsread.m  Size: 11kB   By:
carandraug

<http://savannah.gnu.org/bugs/download.php?file_id=33929>

    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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