This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[libstdc++/61601] Throws an exception on stack overflow?
- From: Tim Shen <timshen at google dot com>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 3 Feb 2015 13:26:08 -0800
- Subject: [libstdc++/61601] Throws an exception on stack overflow?
- Authentication-results: sourceware.org; auth=none
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