Bug #67319 [Opn->Nab]: Error with an infinite recursion in __toString().
| From: | johannes@php.net | Date: | Wed, 21 May 2014 16:52:10 +0000 |
| Subject: | Bug #67319 [Opn->Nab]: Error with an infinite recursion in __toString(). | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185885@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67319&edit=1
ID: 67319
Updated by: johannes@php.net
Reported by: Sysaninster at gmail dot com
Summary: Error with an infinite recursion in __toString().
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: centos 6.5
PHP Version: 5.5.12
Block user comment: N
Private report: N
New Comment:
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
This is a stack overflow we can't detect in a good way. Only thin would be an arbitrary limit,
which might be too low for some valid use cases on one machine but might be too high on a different
machine.
Be careful with recursion.
Previous Comments:
------------------------------------------------------------------------
[2014-05-21 14:57:11] Sysaninster at gmail dot com
Description:
------------
Error with an infinite recursion in __toString().
I get in CLI:
Segmentation fault
When I try execute this code in php-fpm, then I get an error in fpm log:
[21-May-2014 16:41:48] WARNING: [pool logic] child 8686 exited on signal 11 (SIGSEGV) after
957.896252 seconds from start
Test script:
---------------
class foo {
public $parent = null;
public function __toString() {
return sprintf('some %s', $this->public);
}
}
$test = new \foo();
$test->public = $test;
echo $test;
Expected result:
----------------
Fatal error: Maximum function nesting level of '500' reached, aborting! in /home
/sysanin/test.php on line 5
Call Stack:
0.0002 118064 1. {main}() /home/sysanin/test.php:0
0.0003 118372 2. foo->__toString() /home/sysanin/test.php:12
0.0003 118428 3. sprintf() /home/sysanin/test.php:6
0.0003 118720 4. foo->__toString() /home/sysanin/test.php:6
0.0003 118776 5. sprintf() /home/sysanin/test.php:6
0.0003 119068 6. foo->__toString() /home/sysanin/test.php:6
0.0003 119136 7. sprintf() /home/sysanin/test.php:6
0.0003 119428 8. foo->__toString() /home/sysanin/test.php:6
...
0.0015 203708 493. sprintf() /home/sysanin/test.php:6
0.0015 204000 494. foo->__toString() /home/sysanin/test.php:6
0.0015 204056 495. sprintf() /home/sysanin/test.php:6
0.0015 204348 496. foo->__toString() /home/sysanin/test.php:6
0.0015 204404 497. sprintf() /home/sysanin/test.php:6
0.0015 204696 498. foo->__toString() /home/sysanin/test.php:6
0.0015 204752 499. sprintf() /home/sysanin/test.php:6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67319&edit=1