Edit report at https://bugs.php.net/bug.php?id=60927&edit=1

 ID:                 60927
 Updated by:         johan...@php.net
 Reported by:        jimmy at axenhus dot com
 Summary:            Recursive functions for preg_replace_callback causes
                     SEGFAULT
-Status:             Bogus
+Status:             Not a bug
 Type:               Bug
 Package:            PCRE related
 Operating System:   Ubuntu 11.04
 PHP Version:        5.3.9
 Block user comment: N
 Private report:     N

 New Comment:

.


Previous Comments:
------------------------------------------------------------------------
[2012-01-29 19:47:53] johan...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Recursion ends in a stack overflow. A stack overflow makes the operating system 
kill the process.

------------------------------------------------------------------------
[2012-01-29 19:33:01] jimmy at axenhus dot com

Description:
------------
Using recursive functions for preg_replace_callback that never ends PHP will 
exit with a SEGFAULT (unexpected signal 11) due to a function stack overflow.

It's expected that it should never end and therefore PHP should abort the 
execution. However PHP should output a helpful error message rather than just 
aborting it. Depending on your code this could be a major issue to debug. (I 
was using Drupal and it look me hours to find the source.)

Test script:
---------------
<?php

function a() {
  b();
}
function b() {
  a();
}

preg_replace_callback("/0/s", 'a', "0");
echo "We made it my friend!";


Expected result:
----------------
Some sort of error message that the callback stack limit has been reached.

Actual result:
--------------
A 500 Internal Server error (Apache with mod_fcgid) and a SEGFAULT in the error 
log.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60927&edit=1

Reply via email to