D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7928 - Regex regression - out of memory.
Summary: Regex regression - out of memory.
Status: RESOLVED DUPLICATE of issue 7442
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-16 12:49 UTC by Vincent
Modified: 2012-04-19 08:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vincent 2012-04-16 12:49:02 UTC
I had working program with reg.exp. for parsing HTTP requests:
regex(`^(\w+)\s+((\w+)://([^/]+)(\S+))\s*(.*)`)

From some D2 version program stopped compiling with exception "out of memory".
More simpler expression compiles fine: regex(`^([-a-zA-Z]+):\s*(.*)`);
Comment 1 Dmitry Olshansky 2012-04-16 23:27:27 UTC
Works for me on 2.059. It might be the case that you use ctRegex then it very well may run out of memory because of Issue 1382.
Comment 2 Vincent 2012-04-17 00:16:55 UTC
> It might be the case that you use ctRegex...

Function 'regex' returns Regex object, not ctRegex. BUT my feeling is that long compiling of my small program caused by 'compile time Regex'! Probably some trick in library makes all Regex as 'compile time'?
Comment 3 Dmitry Olshansky 2012-04-17 00:20:35 UTC
Aha, I think I know what it is! Give me the prize ;)

Don't you have globals defined like this?

auto httpReqRegex = regex(`^(\w+)\s+((\w+)://([^/]+)(\S+))\s*(.*)`);

then it tries to init it at compile time. That makes it _parse_ them all at CTFE.

Nice feature if it wasn't for bugs. The workaround is to init them in the module constructor static this(){ ... )
Comment 4 Vincent 2012-04-17 00:49:18 UTC
(In reply to comment #3)
> Aha, I think I know what it is! Give me the prize ;)
> Don't you have globals defined like this?

Yep, OF COURSE I made 'em global! Take your prize:
(*)(*)
(tits) :)))

Damn... what a hell that CTFE meddle into my code when I didn't ask for it??

> The workaround is to init them in the module constructor static this(){ ... )

Thanks, Dmitry! Will use it.
Comment 5 Dmitry Olshansky 2012-04-19 08:53:00 UTC
Ok I'm marking this as duplicate of 7442 as it is the root of problem with 'Out of memory on static regex' even if static-ness wasn't intended.

*** This issue has been marked as a duplicate of issue 7442 ***