This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libstdc++/61601] Throws an exception on stack overflow?


Currently std::regex uses recursion for traversing its internal NFA.

When:
1) the user input string for being matched is too long;
2) there're too many NFA states,

stack overflow will happen. 2) can be avoided (as we already did) by
limiting total number of NFA states. For 1) however, I think throwing
std::regex_error::error_stack is appropriate, but I don't know if we
can do that without manually keeping track of the recursion depth.

I'm typically asking: is there a portable way to set a temporary
thread local stack overflow (SIGSEGV?) handler when matching starts,
and reset it back when matching ends/quits ?

Alternatively, I can rewrite it to non-recursive, but it will use a
stack container on the heap and I'm not sure if it will be slowed
down.


-- 
Regards,
Tim Shen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]