Bug 67212 - Infinite recurtion in std::regex_match
Summary: Infinite recurtion in std::regex_match
Status: RESOLVED DUPLICATE of bug 61582
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 5.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-14 08:17 UTC by Jakob Truelsen
Modified: 2015-08-14 17:54 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Crashing program (1.10 KB, text/cpp)
2015-08-14 08:17 UTC, Jakob Truelsen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakob Truelsen 2015-08-14 08:17:33 UTC
Created attachment 36184 [details]
Crashing program

The following code, crashes for some instances of line (as given in the attachment):

std::regex lineExp("tpie::update_fractions\\([ ]*\"([^\"]+)\"[ ]*,[ ]*([^, ]+)[ ]*,[ ]*([^\\) ]+)[ ]*\\);.*", std::regex::extended);
std::string line = <some_long_string_here>
std::smatch matches;
std::regex_match(line, matches, lineExp);


The crash ocure as we are running out of stack space in some possible infinite recurtion. The context of the code can be seen here https://github.com/thomasmoelhave/tpie/blob/cpp11-cleanup/tpie/fractional_progress.cpp#L64

The issue is triggered by:
g++ -std=c++11 test2.cc && ./a.out
Comment 1 Tim Shen 2015-08-14 17:01:00 UTC
Mark as duplicate, since it's as well about stack overflow.

*** This bug has been marked as a duplicate of bug 61582 ***
Comment 2 Tim Shen 2015-08-14 17:54:11 UTC
This isn't an "infinite" recursion, but just a deep one. I haven't implement heap allocation and manual recursion yet. In the mean time, you may compile your code with -O2 (tail recursion elimination may help), set a larger stack size, or use -fsplit-stack.