bugGNU Octave - Bugs: bug #35961, malformed regexp pattern causes...

 
 

bug #35961: malformed regexp pattern causes segfault

Submitted by:  None
Submitted on:  Fri 23 Mar 2012 11:50:06 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 3 - LowItem Group: Segfault, Bus Error, etc.
Status: FixedAssigned to: None
Originator Name: Mech MonOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.1
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sun 25 Mar 2012 04:38:21 AM UTC, comment #5:

The segfault was caused by an off-by-1 error in a test condition involving lookbehind operators. I have committed a patch to the stable branch of Octave (http://hg.savannah.gnu.org/hgweb/octave/rev/b472596cd7b9). This will show up in the next bug fix release 3.6.2. If you need it today you can build from the stable Mercurial sources, but it is not so easy to do so on MS Windows platforms.

Rik <rik5>
Project Administrator
Sun 25 Mar 2012 04:28:05 AM UTC, comment #4:

Regular expressions come in different varieties. The test site regexpal.com uses Javascript for regular expressions and Javascript has different support and interpretations than the Perl Compatible Regular Expressions (PCRE) that Octave uses. Your best bet is probably to debug the pattern in Octave. Start with a small nucleus of a pattern, such as [XCZF], and slowly add one bit of the pattern at a time.

Rik <rik5>
Project Administrator
Sun 25 Mar 2012 02:16:18 AM UTC, comment #3:

I changed the double quotes to single quotes and the warnings didn't flag as you suggested.

According to http://regexpal.com/, The string is valid, yet incomplete. I need to match:
X[65.989*#101+#103+#525+#127]
C1089.517
Z8.34
F[990.574#1431.275]

As it is the space between the "C to Z" and the "Z to F" is selected. Not an issue I can deblank() the line to trim them.
The "#101+#103+#525+#127" numbers are machine variables. In a separate line I have turned them into variables(VAR101,VAR103,VAR525,VAR127) and initialized them to zero.
The brackets delineate a formula to be evaluated.
What I am pulling out of this line is a set of coordinates to be plotted.

Anonymous
Sat 24 Mar 2012 10:30:03 PM UTC, comment #2:

It's true that the interpreter should not crash regardless of the input.

On the other hand, I don't think the search pattern is valid. To begin, the first list atom '[XCZF' is not closed. Second, the pattern is using a lookbehind assertion when I think it needs a lookahead assertion. The four warnings are coming because the pattern is using double quotes and undergoing interpretation. From the regexp documentation,

In this case, I think you meant '\d' to match a digit but it is being interpreted as a literal 'd'. The literal character "\[" is reduced to '[' and is creating a new list atom which is really not what you want.

I don't know exactly what you are trying to parse out of your string but the pattern below, which works, might be something to build from. It returns the start positions in the string of an expression which is (X or C or Z or F) followed by, but not included in the match, a bracket or digit, zero or more non-whitespace characters, and an optional closing bracket.

Rik <rik5>
Project Administrator
Fri 23 Mar 2012 01:53:14 PM UTC, comment #1:

Confirmed in dev...

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Fri 23 Mar 2012 11:50:06 AM UTC, original submission:

I am parsing a text file and when I try this line:

It crashed 3.6.1 and 3.4.3 and 3.2.4

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jordigh (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
    Sun 25 Mar 2012 04:38:21 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Sun 25 Mar 2012 03:33:29 AM UTCrik5Priority5 - Normal=>3 - Low
      Summaryregexp causes Crash=>malformed regexp pattern causes segfault
    Fri 23 Mar 2012 01:53:14 PM UTCjordighStatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1