www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12713] New: std.regex.regex crashes with SEGV, illegal

https://issues.dlang.org/show_bug.cgi?id=12713

          Issue ID: 12713
           Summary: std.regex.regex crashes with SEGV, illegal instruction
                    resp. assertion failure with certain bad input
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: yxcvbasdfgqwert02 gmx.de

Created attachment 1356
  --> https://issues.dlang.org/attachment.cgi?id=1356&action=edit
Source code for test case

The bad regular expression "[[a-z]([a-z]|(([[a-z])))" seems to run an
unexpected execution path during regular expression compilation which ended up
in a segmentation fault (if compiled with -release) or an assertion failure (if
not).
Verified with dmd 2.065 and ldc2-0.12-1 (the latter causes an 'illegal
instruction' crash if compiled with -release). 

Instead of crashing, the bad expression should be rejected with a proper
exception like "wrong character class" (as for other syntactically wrong
expressions).

Note: the terms "[[a-z]" were intended to be "[\\[a-z]".

--
May 07 2014