Closed josephch closed 4 weeks ago
You are using greedy matching. So it's trying to match as much it can and store every step in between to backtrack. It's using system stack for it. I recommend replacing greedy matches .*
with lazy ones .*?
or whenever possible possessive ones .*+
Thank you Hana
Crash did not happen when I changed regex to ".{0,1023}(ld.{0,1023}):[[:blank:]](cannot find.*)"
to limit the stack usage.
If possible could you please provide a fix for this? Even an exception could be fine, as it would be a defined behaviour, and avoid memory corruption.
Unfortunately this is impossible to fix, at least with current design of whole CTRE. Size of remaining stack is unknown (and various platforms has different sizes, and main/threads can differ too).
It's same as with C++, no one stops you from using all your stack, it's a code.
One thing which can be done is to use fast_match
/ fast_search
from DFA branche. Which builds DFA and exchange compile-time speed + ability of capture content for matching bounded memory and performance.
Thank you Hana for the explanation
Thanks for filling the issue and I hope I will be able to help you with next one better.
Segmentation fault is seen during pattern match. Below code always give segmentation fault GCC version used : 13.1.0. Reproduced in ctre main branch rev acb2f4d.