You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
<regex>: Grouping within repetition causes regex stack error #997
vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.
Boost.Regex actually can run into stack overflow and recover from it by itself. See BOOST_REGEX_RECURSIVE in its documentation. This strategy is better for performance of normal cases than avoiding stack allocation or trying to limit them to some amount.
There are actually few ways to accomplish this, and catching EXCEPTION_STACK_OVERFLOW is just one of them. Another is to call GetCurrentThreadStackLimits/SetThreadStackGuarantee and stand away from dangerously low stack.
We talked about this at the weekly maintainer meeting (see #1488). We concluded that reducing the recursion limit would likely cause more problems than it "solves", so we believe that we can't make changes here until vNext.
I believe we could avoid stack overflow issues while preserving bincompat by rewriting the header-only matching functions to traverse the NFA nodes while allocating "frames" on the heap. We can't mess with the data structure itself, but we can change how we process it. It would be a big change though.
Activity
AlexGuteniev commentedon Jul 5, 2020
Boost.Regex actually can run into stack overflow and recover from it by itself. See
BOOST_REGEX_RECURSIVEin its documentation. This strategy is better for performance of normal cases than avoiding stack allocation or trying to limit them to some amount.There are actually few ways to accomplish this, and catching
EXCEPTION_STACK_OVERFLOWis just one of them. Another is to callGetCurrentThreadStackLimits/SetThreadStackGuaranteeand stand away from dangerously low stack.StephanTLavavej commentedon Aug 10, 2022
We talked about this at the weekly maintainer meeting (see #1488). We concluded that reducing the recursion limit would likely cause more problems than it "solves", so we believe that we can't make changes here until vNext.
StephanTLavavej commentedon Apr 25, 2025
Trying to recover from stack overflow would be extremely squirrely and I am strongly opposed to such attempts. 🐿️
Alex Guteniev (@AlexGuteniev) observed that Boost.Regex dropped its "recursive" mode in 1.76.0; compare its 1.75.0 docs to 1.76.0 docs.
I believe we could avoid stack overflow issues while preserving bincompat by rewriting the header-only matching functions to traverse the NFA nodes while allocating "frames" on the heap. We can't mess with the data structure itself, but we can change how we process it. It would be a big change though.
StephanTLavavej commentedon Nov 3, 2025
The stack overflow has been fixed, but we're throwing a
regex_error(error_stack)now.