www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12076] New: [REG 2.065 HEAD] ctRegex range violation

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12076

           Summary: [REG 2.065 HEAD] ctRegex range violation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: mk krej.cz



I get range violation in ctRegex after this commit:
https://github.com/D-Programming-Language/phobos/commit/f1eadb913608ad1e1acd800e6c36b2b50b2a9f12

import std.stdio, std.regex;

void main()
{
        auto RE = ctRegex!(r"(?<!x\w+)\s(\w+)");
        string s = "one two";

        auto m = matchFirst(s, RE);
}

---------------------

core.exception.RangeError std.regex(5982): Range violation
----------------
./regexbug(_d_array_bounds+0x16) [0x80ea846]
./regexbug() [0x80f2402]
./regexbug( trusted bool std.regex.ctRegexImpl!("(?<!x\w+)\s(\w+)",
[]).func(ref
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char).BacktrackingMatcher).matcher_0(ref
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char,
std.regex.Input!(char).Input.BackLooper).BacktrackingMatcher)+0x157)
[0x80d1d37]
./regexbug( trusted bool
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char,
std.regex.Input!(char).Input.BackLooper).BacktrackingMatcher.matchImpl()+0x39)
[0x80e4979]
./regexbug( trusted bool std.regex.ctRegexImpl!("(?<!x\w+)\s(\w+)",
[]).func(ref
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char).BacktrackingMatcher)+0x1c1)
[0x80d18f1]
./regexbug( trusted bool
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char).BacktrackingMatcher.matchImpl()+0x39)
[0x80e30b1]
./regexbug( trusted bool
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char).BacktrackingMatcher.matchFinalize()+0x42)
[0x80e2e6a]
./regexbug( trusted bool
std.regex.BacktrackingMatcher!(true).BacktrackingMatcher!(char).BacktrackingMatcher.match(std.regex.Group!(uint).Group[])+0xdd)
[0x80e2fcd]
./regexbug( trusted std.regex.Captures!(immutable(char)[], uint).Captures
std.regex.__T9matchOnceS613std5regex28__T19BacktrackingMatcherVb1Z19BacktrackingMatcherTS3std5regex19__T11StaticRegexTaZ11StaticRegexTAyaZ.matchOnce(immutable(char)[],
std.regex.StaticRegex!(char).StaticRegex)+0xe0) [0x80e37e8]
./regexbug( safe std.regex.Captures!(immutable(char)[], uint).Captures
std.regex.matchFirst!(immutable(char)[],
std.regex.StaticRegex!(char).StaticRegex).matchFirst(immutable(char)[],
std.regex.StaticRegex!(char).StaticRegex)+0x29) [0x80e36f1]
./regexbug(_Dmain+0x26002) [0x80d1722]
./regexbug(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll().void __lambda1()+0x10) [0x80ec168]
./regexbug(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())+0x18) [0x80ec0e0]
./regexbug(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll()+0x27) [0x80ec12f]
./regexbug(void rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate())+0x18) [0x80ec0e0]
./regexbug(_d_run_main+0x117) [0x80ec077]
./regexbug(main+0x14) [0x80e7fdc]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xeb5f2ca6]
./regexbug() [0x80ab681]

---------------------------

Normal regex() works.

DMD32 D Compiler v2.065-devel-e493324
Linux

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 04 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12076


Martin Krejcirik <mk krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[REG 2.065 HEAD] ctRegex    |ctRegex range violation
                   |range violation             |
           Severity|regression                  |normal



ok, that was a bit premature, looks like not a regression and not caused by the
commit from comment 0, so downgrading now.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 05 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12076


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |dmitry.olsh gmail.com



13:00:23 PST ---
https://github.com/D-Programming-Language/phobos/pull/1958

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12076




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/01e0acddd64449f5b4bd98aaeb59ac41bb5a8f19
fix issue 12076

Lookaround in ctRegex used wrong number of total captures thus missing
both a bit of optimization AND a special case of 0 matches.
The latter is the reason of range violation in issue 12076.

https://github.com/D-Programming-Language/phobos/commit/1ca127265ae7db2f612411672410a9945c240fa1


fix issue 12076

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 24 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12076


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 24 2014