bugGNU Octave - Bugs: bug #29438, regexp: Crash with named...

 
 

bug #29438: regexp: Crash with named subexpressions and nested parentheses

Submitted by:  None
Submitted on:  Sun 04 Apr 2010 10:15:13 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Segfault, Bus Error, etc.
Status: FixedAssigned to: David Bateman <dbateman>
Originator Name: Philipp K.Originator Email: -unavailable-
Open/Closed: ClosedRelease: 3.3.51
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Tue 13 Apr 2010 09:59:03 PM UTC, comment #4:

Ok, the savannah tracker doesn't like attached files with the same name.. Here is the second patch again]

D.

David Bateman <dbateman>
Project MemberIn charge of this item.
Tue 13 Apr 2010 09:57:03 PM UTC, comment #3:

Ok, the fix I posted isn't quite correct and causes another issue. Please find attached an additional patch that should be applied after the first patch

D.

David Bateman <dbateman>
Project MemberIn charge of this item.
Fri 09 Apr 2010 11:33:13 PM UTC, comment #2:

Its not a matter of failing to initialize a variable, but rather as the original poster pointed out using the grouping operator in the pattern for a named token cases an issue. The reason is that pcre_exec returns a value with the number of matches it finds, but this return value is abused to pass zero-length matches for the parentheses. These zero length matches weren't correctly ignored for named tokens resulting in octave looking for the second named token in an internal array when only one was defined and thus a segfault.

Prove is that although

s = regexp('qwe int asd', ['(?<typestr>(int))'], 'names');

segfaults

s = regexp('qwe int asd', ['(?<typestr>int)'], 'names');

doesn't. Trivial changeset attached that I have pushed

(file #20177)

David Bateman <dbateman>
Project MemberIn charge of this item.
Mon 05 Apr 2010 10:35:08 PM UTC, comment #1:

We seem to be failing to properly initialize some variables in regexp. After a single call to regexp all variables are properly initialized and the problem code works. It is only the first invocation of regexp which has problems.

Working code:
-------------------------------------------------------
sh> octave

octave:1> regexp('a','a')
ans = 1
octave:2> s = regexp('qwe int asd', ['(?<typestr>(int))'], 'names');
octave:3> s
s =
{
typestr = int
}
--------------------------------------------------------
Failing code:
sh> octave
octave:1> s = regexp('qwe int asd', ['(?<typestr>(int))'], 'names');
--------------------------------------------------------

Rik <rik5>
Project Administrator
Sun 04 Apr 2010 10:15:13 PM UTC, original submission:

Attempting to subgroup a named parenthesized subexpression in a regexp results in a crash, see below for an example.
This happens in a freshly built Octave from the repository as well as the one provided by Ubuntu.

octave:1> ver
----------------------------------------------------------------------
GNU Octave Version 3.3.51+
GNU Octave License: GNU General Public License
Operating System: Linux 2.6.31-20-generic-pae #58-Ubuntu SMP Fri Mar 12 06:25:51 UTC 2010 i686
----------------------------------------------------------------------
no packages installed.
%% This is the culprit v v
octave:2> s = regexp('qwe int asd', ['(?<typestr>(int))'], 'names');
panic: Segmentation fault -- stopping myself...
attempting to save variables to `octave-core'...
save to `octave-core' complete
Segmentation fault

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #20177:  patch.regexp added by dbateman (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dbateman (Updated the item)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (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 project members can vote.

     

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

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 15 Apr 2010 10:36:27 PM UTCdbatemanOpen/ClosedOpen=>Closed
    Fri 09 Apr 2010 11:33:13 PM UTCdbatemanAttached File-=>Added patch.regexp, #20177
      StatusConfirmed=>Fixed
      Assigned toNone=>dbateman
    Mon 05 Apr 2010 10:35:07 PM UTCrik5StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1