[php-src] Issue #7749: Segfault when recursive call is made

From: Date: Sat, 11 Dec 2021 16:41:08 +0000
Subject: [php-src] Issue #7749: Segfault when recursive call is made
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238338@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7749 Comment Author: mvorisek ``` <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); class Product { private array $groups = []; public function __call($name, $args): void { if ($name !== 'addGroup') { throw new \Exception(); } [$group] = $args; $group->addProduct($this); $this->groups[] = $group; } } class Group { private array $products = []; public function __call($name, $args): void { if ($name !== 'addProduct') { throw new \Exception(); } [$product] = $args; static $counter; $counter++; if (($counter % 100_000) === 0) { var_dump(($counter / 1000_000) . ' M'); } $product->addGroup($this); $this->products[] = $product; } } $product = new Product(); $group = new Group(); $product->addGroup($group); ``` with 20GB memory limit, the modified example /w magic method above, can do 19M iterations and then ends with OOM error. so the issue is not magic/non-magic method nor issue in "stack overflow in zend_execute.c" what are the conditions to trigger a "system stack overflow" and can they be mitigated like setting bigger system limit when php interpreter is started?

« previous php.bugs (#238338) next »