preg_match_all('/(a)*/', str_repeat('a', 1000), $matches);
(edit: change the regexp a bit to make it simpler while still crashing)
I ran it on PHP 5.3.5 with Apache 2.0 and it crashes the server. If I change 339 to 338 it doesn't crash anymore, so it seems like a bug to me. I tried reporting it to http://bugs.php.net/ but it's down. Is this a PHP bug? Does it crash for anyone else?
Edit: Changing the code to
preg_match_all('/(?:a)*/', str_repeat('a', 339), $matches);
allows for a longer string before crashing. If it doesn't crash, try increasing the string length by a factor of 10 or 100 as it may be a memory issue and you may have more memory.
Edit 2: the crash is a complete process crash, on Windows 7 I get the "End task" message instantaneously after execution.
Edit 3: if the crash is due to too much backtracing, and the above example clearly can cause it, the following should not:
preg_match('/[^"\']*(;|$)/',
str_repeat('x', 1000), $matches);
This is my actual code that's crashing. It's simply meant to split multiple SQL queries by ;, while allowing ; inside single or double quotes. Why is this causing so much backtracing, and how can I fix it?