[Bug libstdc++/61601] C++11 regex resource exhaustion
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 3 04:15:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61601
--- Comment #9 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Tim Shen from comment #7)
> (In reply to Maksymilian Arciemowicz from comment #6)
> > > Do you have any other testcases?
> >
> > for trunk? maybe you have to use ::regex_match
>
> std::regex_match("findme", std::regex("(.*{100}{200}findme)"));
>
> there's no memory problem, it just takes exponentially long time to run
> (which is expected when using backtracking).
>
> To avoid it, you can use Thompson NFA:
>
> #define _GLIBCXX_REGEX_USE_THOMPSON_NFA
> #include <regex>
>
> int main (int argc, char *argv[])
> {
> std::regex_match("findme", std::regex("(.*{100}{200}findme)",
> std::regex_constants::extended));
>
> return 0;
>
> }
>
> Notice that for now Thompson NFA doesn't support ECMAScript.
Are you still working on this?
More information about the Gcc-bugs
mailing list