Bug 16626 – [Reg 2.073] extreme CTFE memory usage with compile time regex

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-19T23:01:00Z
Last change time
2017-01-17T11:24:44Z
Keywords
pull
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2016-10-19T23:01:38Z
Building a debug tests of Higgs[¹] doesn't finish building and runs out of memory with dmd-2016-10-10 (v2.073.0-master-9a935f6). Only takes about 2GB with dmd-2016-10-09 (v2.073.0-master-321c95e). According to verbose output it hangs at `semantic3 parser`. Digger says it's caused by https://github.com/dlang/phobos/pull/4286. [¹]: https://github.com/higgsjs/Higgs
Comment #1 by code — 2016-10-19T23:07:58Z
Seems to happen for 2 ctRegex to filter out non-alphanumerical characters. auto nonAlnum = ctRegex!(`[^\w]`w); enum notAlnum = ctRegex!(`[^0-9|a-z|A-Z]`, "g");
Comment #2 by code — 2016-10-23T22:50:13Z
From Dmitry https://github.com/dlang/phobos/pull/4286#issuecomment-255182046 > The new version is more demanding on memory during CTFE so yeah, most likely it now fails for some patterns. Dunno what to do here would really love to see the new engine sometime soon. That might still take a while and in the meantime such simple ctRegex eat up 16GiB (kill my project tester https://ci.dawg.eu/ btw). If we can't really support the NFA kickstarter in CTFE, then we should just disable it for now.
Comment #3 by dmitry.olsh — 2016-10-24T19:21:08Z
Comment #4 by code — 2016-12-24T10:55:31Z
Comment #5 by code — 2016-12-24T16:06:49Z
More specifically this commit https://github.com/dlang/phobos/commit/e98fa4ad5ad39487844c91357cfec4f698e88230 is responsible for the high memory usage. Also both, regex and ctRegex, trigger the bug if initialized during CTFE. enum notAlnum = regex(`[^0-9|a-z|A-Z]`); enum ctNotAlnum = ctRegex!(`[^0-9|a-z|A-Z]`); https://github.com/dlang/phobos/pull/4995
Comment #6 by github-bugzilla — 2016-12-26T23:33:37Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/07090ae2fdaddd1c40b8c149f32733e908094ac3 disable kickstart in ctfe to workaround Issue 16626 - consumes too much memory, introduced by e98fa4ad5ad39487844c91357cfec4f698e88230 (#4286) https://github.com/dlang/phobos/commit/9cbc862544a9a4afa14bb526ec4aff7792a71e49 Merge pull request #4995 from MartinNowak/fix16626 disable kickstart in ctfe to workaround Issue 16626
Comment #7 by github-bugzilla — 2017-01-07T03:03:20Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/07090ae2fdaddd1c40b8c149f32733e908094ac3 disable kickstart in ctfe to workaround Issue 16626 https://github.com/dlang/phobos/commit/9cbc862544a9a4afa14bb526ec4aff7792a71e49 Merge pull request #4995 from MartinNowak/fix16626
Comment #8 by github-bugzilla — 2017-01-16T23:26:14Z
Commits pushed to newCTFE at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/07090ae2fdaddd1c40b8c149f32733e908094ac3 disable kickstart in ctfe to workaround Issue 16626 https://github.com/dlang/phobos/commit/9cbc862544a9a4afa14bb526ec4aff7792a71e49 Merge pull request #4995 from MartinNowak/fix16626