Using std::regex_match on a big enough target sequence is causing a segmentation fault here. I guess its due to stackoverflow. I noticed, that most often the segmentation fault is due to a "stupid" regex pattern in combination with large enough data.
Is there any way to prevent the code from crashing? So i would like to warn the user when std::regex_match is failing due to stackoverflow and then continue normally. Up to now I can't avoid a fatal SIGSEGV termination exactly due to this std::regex_match failure.
I tried already the error_stack constant, but it seems like it is not working (std::regex_match is not throwing?!).
Following an illustrative example for std::regex_match SIGSEGV due to a too large target sequence
#include <iostream>
#include <regex>
int main()
{
std::regex r("^.*$");
std::smatch m;
std::string str;
for(size_t i = 0; i < 2e4; ++i)
str += char(rand()%(127-32)+32);
std::regex_match(str,m,r);
return 0;
}
Thank you in advance!