#43187 [NEW]: Recursive loop crashes php instead of emitting error

From: Date: Sun, 04 Nov 2007 20:06:38 +0000
Subject: #43187 [NEW]: Recursive loop crashes php instead of emitting error
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-119267@lists.php.net to get a copy of this message
From: thuejk at gmail dot com Operating system: Linux PHP version: 5.2.4 PHP Bug Type: Reproducible crash Bug description: Recursive loop crashes php instead of emitting error Description: ------------ When running a recursive loop with lots of iterations, PHP will segfault. This will usually be a problem when you write buggy code by accident, but I guess it is possible to imagine sane programs which uses lots of recursive calls. In any case, it is somewhat hard to debug the crash when it happens, because you do not get an error message when running it in a browser. Reproduce code: --------------- <?php $i=0; function f() { global $i; printf("%d\n", $i++); f(); } f(); ?> Expected result: ---------------- (Ignoring the fact that the posted function is tail recursive, and therefore could be rewritten as a non-recursive loop) PHP should emit an E_ERROR before it runs out of space. Preferably also an E_RECOVERABLE_ERROR or E_WARNING a little before it really runs out of space. Actual result: -------------- $ php test.php 1 2 3 [...] 29066 29067 zsh: segmentation fault php test.php -- Edit bug report at http://bugs.php.net/?id=43187&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43187&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43187&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43187&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43187&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43187&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43187&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43187&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43187&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43187&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43187&r=support Expected behavior: http://bugs.php.net/fix.php?id=43187&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43187&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43187&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43187&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43187&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43187&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43187&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43187&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43187&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43187&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43187&r=mysqlcfg

« previous php.bugs (#119267) next »