Edit report at https://bugs.php.net/bug.php?id=49664&edit=1
ID: 49664 Comment by: cf0hay at gmail dot com Reported by: patrik dot lermon at gmail dot com Summary: Clone causes Segmentation fault Status: Not a bug Type: Bug Package: Reproducible crash Operating System: Linux PHP Version: 5.*, 6 (2009-09-20) Block user comment: N Private report: N New Comment: > Infinite recursion crashes. There's no fix for that. Err, what? $ php -r 'function a(){ a(); } a();' PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in Command line code on line 1 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in Command line code on line 1 This is the intended behaviour on infinite recursion, not a segmentation fault. I wouldn't be surprised this could lead a security problem rather just a simple crash. Previous Comments: ------------------------------------------------------------------------ [2012-12-18 23:53:05] kurt at kurtrose dot com Python handles this kind of recursion fine: class F(object): def __repr__(self): return self.__repr__() >>> repr(F()) File "<stdin>", line 2, in __repr__ File "<stdin>", line 2, in __repr__ ... File "<stdin>", line 2, in __repr__ File "<stdin>", line 2, in __repr__ RuntimeError: maximum recursion depth exceeded No segfault. ------------------------------------------------------------------------ [2009-10-19 15:31:17] patrik dot lermon at gmail dot com I don't agree. Perhaps my knowledge is not detailed enough, but an infinte recursion should: a) run out of memory and die, or b) detect the recursion and die. In both these cases PHP should die in a controlled manner, not segfault. My understanding is that segfault is never ok - that means the code is faulty. ------------------------------------------------------------------------ [2009-10-19 15:10:24] j...@php.net Infinite recursion crashes. There's no fix for that. ------------------------------------------------------------------------ [2009-09-28 12:06:43] patrik dot lermon at gmail dot com I get the same result with http://snaps.php.net/php5.3-latest.tar.gz on Slackware. ------------------------------------------------------------------------ [2009-09-25 07:50:31] patrik dot lermon at gmail dot com I am aware that the cloning will be recursive in some circumstances, but PHP should not segfault because of this. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=49664 -- Edit this bug report at https://bugs.php.net/bug.php?id=49664&edit=1