[Bug libstdc++/61601] C++11 regex resource exhaustion
timshen at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 2 00:37:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61601
--- Comment #7 from Tim Shen <timshen at gcc dot gnu.org> ---
(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.
More information about the Gcc-bugs
mailing list