-
Notifications
You must be signed in to change notification settings - Fork 7.8k
stack overflow when var serialization in ext/standard/var #15169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
can be reproduced with php 8.2 |
Simpler reproducer: <?php
class Node
{
public $next;
}
$firstNode = new Node();
$node = $firstNode;
for ($i = 0; $i < 200000; $i++) {
$newNode = new Node();
$node->next = $newNode;
$node = $newNode;
}
serialize($firstNode); We could add a manual stack limit check in Unfortunately we will also enter deep recursion when destroying |
Yeah it's crashing even without serialize on object dtor recursive destroying. So we have it in serialize, obj dtor and json_encode and I wouldn't be suprised if there are more places causing the crash. Those |
I don't see issues with that 👍 It may be worth it to run a benchmark just to be sure that there is no performance regression. Alternatively we could switch to a non-recursive algorithm, if this does not increase complexity too much. |
…d/var Adding a stack check here as I consider serialization to be a more sensitive place where erroring out with an exception seems appropriate.
* PHP-8.3: Fix GH-15169: stack overflow when var serialization in ext/standard/var
* PHP-8.4: Fix GH-15169: stack overflow when var serialization in ext/standard/var
somehow Alpinelinux s390x builder been stuck after this change so filed #16528 |
Description
The following code:
Resulted in this output:
Valgrind:
PHP Version
PHP 8.4.0-dev
Operating System
ubuntu 22.04
The text was updated successfully, but these errors were encountered: