Bug #77216 [Dup]: recursive generator crash PHP
| From: | nikic@php.net | Date: | Wed, 28 Nov 2018 23:25:37 +0000 |
| Subject: | Bug #77216 [Dup]: recursive generator crash PHP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218199@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77216&edit=1
ID: 77216
Updated by: nikic@php.net
Reported by: dams@php.net
Summary: recursive generator crash PHP
Status: Duplicate
Type: Bug
Package: Reproducible crash
Operating System: Irrelevant
PHP Version: 7.3.0RC6
Block user comment: N
Private report: N
New Comment:
@requinix: In most cases, infinite recursion results in a memory limit error, because recursion is
performed on the heap-allocated VM stack, rather than the C stack. However, if the recursion
involves VM reentry, we do recurse on the C stack, which will ultimately lead to a stack overflow.
This usually either happens because an extension that forces VM reentry is used (most profilers fall
into this category), or because calls are indirected through internal functions (magic methods, or
here, generators).
One "solution" to this problem is to catch the segfault that happens when we hit the stack
guard page and display a nice error message in this case. But nobody has tried to implement this
yet.
Previous Comments:
------------------------------------------------------------------------
[2018-11-28 23:15:33] requinix@php.net
A bit late but
> it should not crash but instead it should throw a memory_limit error,
Only if PHP runs out of memory. With head recursion the stack might run out before memory does.
------------------------------------------------------------------------
[2018-11-28 23:08:19] nikic@php.net
Closing as duplicate of bug #64196, which is our canonical recursion stack overflow bug. All of
these have the same root cause, but I'm not aware of any work to address this issue.
------------------------------------------------------------------------
[2018-11-28 23:07:08] spam2 at rhsoft dot net
EVERY uncontrolled crash is a bug - it's that simple
------------------------------------------------------------------------
[2018-11-28 23:05:02] cmb@php.net
This is a stack overflow caused by infinite recursion of
execute_ex(). I doubt that we can catch such issues without
measurable performance impact. Also, Xdebug has
xdebug.max_nesting_level[1] which should catch such issues during
development. See also bug #69424.
In my opinion, this is not a bug.
[1] <https://xdebug.org/docs/basic>
------------------------------------------------------------------------
[2018-11-28 22:31:43] kalle@php.net
@requinix, despite this being an infinite recursion, it should not crash but instead it should throw
a memory_limit error, so keeping it open. Similar to other bugs I have reported in the past
------------------------------------------------------------------------
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=77216
--
Edit this bug report at https://bugs.php.net/bug.php?id=77216&edit=1