[Bug libstdc++/61601] C++11 regex resource exhaustion
max at cert dot cx
gcc-bugzilla@gcc.gnu.org
Mon Feb 2 18:01:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61601
--- Comment #8 from Maksymilian Arciemowicz <max at cert dot cx> ---
> there's no memory problem, it just takes exponentially long time to run
> (which is expected when using backtracking).
call it cpu resource exhaustion (CWE-400)
>
> 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.
yeap.
try (.*{300}{100}) for _GLIBCXX_REGEX_USE_THOMPSON_NFA. occurs stack exhaustion
like in #61582
More information about the Gcc-bugs
mailing list