bugGNU Octave - Bugs: bug #45031, segfault with regexprep (large...

 
 

bug #45031: segfault with regexprep (large text, many capturing groups)

Submitter:  Carnë Draug <carandraug>
Submitted:  Tue 05 May 2015 06:54:51 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 02 Jun 2015 04:53:33 PM UTC, comment #6: 

Retagging release from 4.0.0-rc4 to 4.0.0.

John W. Eaton <jwe>
Group administrator
Tue 05 May 2015 08:27:38 PM UTC, comment #5: 

It segfault with 8.37-1 too, blame me. I'll create a bugreport at libpcre.

Markus Bergholz <markuman>
Tue 05 May 2015 08:06:32 PM UTC, comment #4: 

No segfault with the new libpcre 8.37-1 version too. So no octave bug.

Markus Bergholz <markuman>
Tue 05 May 2015 07:30:47 PM UTC, comment #3: 

On Arch Linux it's 8.36-2 and crashing. On one Ubuntu machine here it's 8.31-2 and not crashing. So I agree, it's an upstream bug.

Markus Bergholz <markuman>
Tue 05 May 2015 07:21:49 PM UTC, comment #2: 

This is probably important, I am using libpcre version 2:8.35-3.3 (latest on Debian Jessie). So maybe a bug upstream?

Carnë Draug <carandraug>
Group Member
Tue 05 May 2015 07:11:27 PM UTC, comment #1: 

octave rc4 ubuntu

I tried your test code and it did not segfault.

Doug Stewart <dastew>
Tue 05 May 2015 06:54:51 PM UTC, original submission:  

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.

Carnë Draug <carandraug>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #33929:  xlsread.m added by carandraug (11KiB - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by markuman (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by carandraug (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.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-02 jwe Release4.0.0-rc4 4.0.0
    2015-05-06 rik5 StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2015-05-05 carandraug Attached File- Added xlsread.m, #33929

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code