[Solar-talk] Narrowing down the apache crash bug
Andrew Shell
andrew at andrewshell.org
Tue Sep 19 13:53:57 PDT 2006
I've tried to write a stand alone script with as little code as possible
to replicate the error.
Here's what I got.
It doesn't seem to be a problem with preg_replace_callback or what we
are returning. It seems to be a combo of
whitespace chars and number of lines
<?php
// $text = str_repeat("<p>test\n</p>\n", 500); // No Crash
// $text = str_repeat("<p>test</p>\n", 500); // Crash
// $text = str_repeat("<p>test</p>\n", 5); // No Crash
// $text = str_repeat("<p>test\r\n</p>\r\n", 500); // Crash
$text = str_repeat("<p>test\r\n</p>\r\n", 5); // No Crash
$result = preg_replace("{
( # save in $1
^ # start of line (with /m)
<(p) # start tag = $2
\\b # word break
(.*\\n)*? # any number of lines, minimally
matching
</\\2> # the matching end tag
[ \\t]* # trailing spaces/tabs
(?=\\n+|\\Z) # followed by a newline or end
of document
)
}xm",
'x',
$text
);
echo $result;
?>
More information about the solar-talk
mailing list