Bug 7045 – AssertError in std.regex on line 1573

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2011-12-01T13:01:00Z
Last change time
2015-06-09T05:15:10Z
Assigned to
nobody
Creator
issues.dlang

Attachments

IDFilenameSummaryContent-TypeSize
1049relayhosts.dD program which failstext/x-dsrc1573
1050inputTest file that I passed to the D program.text/plain345345

Comments

Comment #0 by issues.dlang — 2011-12-01T13:01:31Z
Created attachment 1049 D program which fails Running the attached program with the attached file (using the latest dmd, druntime, and Phobos), results in this Assertion failure: [email protected](1573): Assertion failure ---------------- ./relayhosts_orig(_d_assertm+0x2a) [0x4d27aa] ./relayhosts_orig() [0x4d698d] ./relayhosts_orig(@safe std.typecons.Tuple!(std.internal.uni.CodepointSet, std.regex.Parser!(immutable(char)[]).Parser.Operator).Tuple std.regex.Parser!(immutable(char)[]).Parser.parseCharTerm()+0x60a) [0x4a04ae] ./relayhosts_orig(@safe void std.regex.Parser!(immutable(char)[]).Parser.parseCharset()+0x1f1) [0x4a0ac1] ./relayhosts_orig(@safe void std.regex.Parser!(immutable(char)[]).Parser.parseAtom()+0xf4) [0x49fa18] ./relayhosts_orig(@trusted void std.regex.Parser!(immutable(char)[]).Parser.parseRegex()+0xb59) [0x49eb91] ./relayhosts_orig(@trusted std.regex.Parser!(immutable(char)[]).Parser std.regex.Parser!(immutable(char)[]).Parser.__ctor!(const(char)[]).__ctor(immutable(char)[], const(char)[])+0x6a) [0x4aeee2] ./relayhosts_orig(@safe std.regex.Regex!(char).Regex std.regex.regex!(immutable(char)[]).regex(immutable(char)[], const(char)[])+0x40) [0x49d8a8] ./relayhosts_orig(_Dmain+0x3b) [0x49d517] ./relayhosts_orig(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x4d2ddf] ./relayhosts_orig(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x4d2986] ./relayhosts_orig(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x42) [0x4d2e32] ./relayhosts_orig(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x4d2986] ./relayhosts_orig(main+0xd3) [0x4d2917] /lib/libc.so.6(__libc_start_main+0xed) [0x7f3dc4bc317d] It happens on both 32-bit and 64-bit Linux. I don't know if it happens on other OSes (though I assume that it does). I was trying to run an example from the newsgroup to benchmark the old std.regex vs the new one, and while the old one worked, the new one failed with the AssertError.
Comment #1 by issues.dlang — 2011-12-01T13:03:30Z
Created attachment 1050 Test file that I passed to the D program.
Comment #2 by hoganmeier — 2011-12-01T17:22:52Z
Why so complicated? import std.regex; void main() { auto pattern = regex(r"^(import|file|binary|config)\s+([^\(]+)\(?([^\)]*)\)?\s*$"); } Taken from rdmd. It fails cause it rejects \( I suggest to turn line 1573 of regex.d (after case State.Escape: switch(current)) into 'assert(0, "Unsupported escape character \\"~cast(char)current);' so one gets a proper error message.
Comment #3 by issues.dlang — 2011-12-01T17:27:49Z
It was someone else's program, and I was in a hurry, so I didn't have time to reduce it properly.
Comment #4 by hoganmeier — 2011-12-06T03:14:54Z
btw, isn't this a regression?
Comment #5 by hoganmeier — 2011-12-06T04:06:55Z
Seems like it was fixed in the meantime. http://www.mail-archive.com/[email protected]/msg70809.html