I can reproduce the issue with your sample repeated until it reaches 1010445 
lines, and with the pattern `^(\d+?);(\d+?);(\d+?);[BCST]+\n(.*?\n)*\1`.  The 
crash seems to be due to an excessive recursion (leading to stack overflow) 
inside libpcre, on which we have no control.
However, your pattern is likely to do this, as you allow for any number of 
optional lines between two identical lines; this basically means that the regex 
can capture the whole file, and has to be matched against the whole file if 
there is no match.  It's sad to ever find a program crashing, but in this case 
there isn't much we can do, and your regular expression is fairly dangerous per 
se, in term of performance and memory usage at the very least -- and most 
distros' libpcre are built to use recursion because it's faster (or so they 
say) but can lead to unavoidable crashes on extreme cases like this.

BTW, I'm not sure it's what you want, but if you choose to be ungreedy on the 
number of lines allowed between the start and end, it is a lot less likely to 
crash (`^(\d+?);(\d+?);(\d+?);[BCST]+\n(.*?\n)*?\1`) -- but it sill will if 
there is no match for one of the first lines.

IMO, this is a case of "wontfix", both because we can't do anything about it, 
and it's caused by a pathological match -- which is exactly what is asked for.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/1586#issuecomment-417852625

Reply via email to