xref: /PHP-7.1/Zend/tests/bug68652.phpt (revision 113213f0)
1--TEST--
2Bug #68652 (segmentation fault in destructor)
3--FILE--
4<?php
5class Foo {
6
7    private static $instance;
8    public static function getInstance() {
9        if (isset(self::$instance)) {
10            return self::$instance;
11        }
12        return self::$instance = new self();
13    }
14
15    public function __destruct() {
16        Bar::getInstance();
17    }
18}
19
20class Bar {
21
22    private static $instance;
23    public static function getInstance() {
24        if (isset(self::$instance)) {
25            return self::$instance;
26        }
27        return self::$instance = new self();
28    }
29
30    public function __destruct() {
31        if (!isset(self::$instance)) return;
32        Foo::getInstance();
33    }
34}
35
36
37$foo = new Foo();
38?>
39--EXPECTF--
40Fatal error: Uncaught Error: Access to undeclared static property: Bar::$instance in %sbug68652.php:%d
41Stack trace:
42#0 %s(%d): Bar::getInstance()
43#1 [internal function]: Foo->__destruct()
44#2 {main}
45  thrown in %sbug68652.php on line %d
46