1
0
mirror of https://github.com/php/php-src.git synced 2026-03-31 20:53:00 +02:00
Files
archived-php-src/Zend/tests/bug68652.phpt
Nikita Popov 502dd99a6c Fix ZEND_NEW live ranges
While the def starts at DO_FCALL, the variable should still be the
result of NEW, not DO_FCALL.

I had to fix the test for #68652, because the code started to
(correctly) free the "new self()" object, which triggered an
infinite destructor loop.
2016-02-13 19:04:54 +01:00

47 lines
974 B
PHP

--TEST--
Bug #68652 (segmentation fault in destructor)
--FILE--
<?php
class Foo {
private static $instance;
public static function getInstance() {
if (isset(self::$instance)) {
return self::$instance;
}
return self::$instance = new self();
}
public function __destruct() {
Bar::getInstance();
}
}
class Bar {
private static $instance;
public static function getInstance() {
if (isset(self::$instance)) {
return self::$instance;
}
return self::$instance = new self();
}
public function __destruct() {
if (!isset(self::$instance)) return;
Foo::getInstance();
}
}
$foo = new Foo();
?>
--EXPECTF--
Fatal error: Uncaught Error: Access to undeclared static property: Bar::$instance in %sbug68652.php:%d
Stack trace:
#0 %s(%d): Bar::getInstance()
#1 [internal function]: Foo->__destruct()
#2 {main}
thrown in %sbug68652.php on line %d