xref: /PHP-7.2/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?>
39OK
40--EXPECT--
41OK
42