|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-12-08 11:58 UTC] deepvavar at mail dot ru
Description:
------------
Can be segmentation fault
Test script:
---------------
<?php
class a
{
public function getNewB()
{
$b = new b();
$b->a = $this;
return $b;
}
}
class b
{
public $a = null;
public $b = null;
}
class x
{
public static $a = null;
public static $b = null;
public static function foo()
{
self::$a = new a();
self::$b = self::$a->getNewB();
self::bar(self::$b);
}
public static function bar($b)
{
$b->b = self::$a->getNewB();
self::bar($b->b);
}
}
x::foo();
Expected result:
----------------
Without segfault
Actual result:
--------------
~$ php test.php
Segmentation fault
~$ php -v
PHP 5.6.22-0+deb8u1 (cli) (built: Jun 13 2016 07:55:54)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
~$ cat /etc/debian_version
8.5
------------------------------------------
Fatal error: Maximum function nesting level of '100' reached, aborting!
Windows, php 5.4
------------------------------------------
> php test.php
fish: “php test.php” terminated by signal SIGSEGV (Address boundary error)
> php -version
PHP 5.6.28 (cli) (built: Nov 9 2016 07:56:15)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
------------------------------------------
# php t.php
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in /t.php on line 29
# php -v
PHP 5.6.28 (cli) (built: Dec 6 2016 22:12:29)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
With php 7.1: Fatal error: Allowed memory size
------------------------------------------
~$ php test.php
Segmentation fault
~$ php -v
PHP 7.0.13-2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.13-2, Copyright (c) 1999-2016, by Zend Technologies
------------------------------------------
$ php test.php
Segmentation fault
$ php -v
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 05:00:01 2025 UTC |
Well, simplified reproduce script: <?php function foo() { foo(); } foo(); Crashes all PHP versions. Anyway, as you insist this is a bug in PHP, I'm re-opening.I don't want introduce recursion limits. This code: public static function bar($b, $i = 0) { if ($i == 15396) { return; } $b->b = self::$a->getNewB(); self::bar($b->b, ++$i); } Says about memory limit problem. This is last good value. For $i == 15397 I get segfault. php doesn't check for availability of the memory (what return malloc/calloc/realloc) or (position) pointer? I don't believe. Ok. What I can for fix or check it? I just want expected behaviour.