Comment #0 by yxcvbasdfgqwert02 — 2014-05-02T15:18:53Z
Created attachment 1349
Source code for test case
Certain expressions/haystacks seem to trigger a memory error in std.regex.bmatch.
In the attached source code, the regular expression is kind-of stupid, however it should be either treated as wrong (std.regex.regex should throw an exception) or should work, but never crash. In the test case, the expression "([a-z]|)" uses an empty string after the OR operator.
The crash also occurred on a more complex expression with 2 OR operators beneath, containing something like "a||b".
Using match instead of bmatch returns the expected result: the expression doesn't match the haystack.
Btw, I used bmatch instead of match because bmatch is way faster (see issue 12690).
Comment #1 by dmitry.olsh — 2014-05-02T21:06:16Z
And on Win32:
object.Error@(0): Access Violation
Got to look in it.
Comment #2 by dmitry.olsh — 2014-05-12T15:35:56Z
https://github.com/D-Programming-Language/phobos/pull/2164
The bug also applies to ctRegex as they share engines.
Reduced test-case:
import std.regex;
void main()
{
assert(bmatch("e@", "^([a-z]|)*$").empty);
assert(bmatch("e@", ctRegex!`^([a-z]|)*$`).empty);
}
Comment #3 by github-bugzilla — 2014-05-13T00:33:52Z