xref: /PHP-8.3/Zend/tests/bug47343.phpt (revision 902d6439)
1--TEST--
2Bug #47343 (gc_collect_cycles causes a segfault when called within a destructor in one case)
3--FILE--
4<?php
5class A
6{
7    public $data = [];
8    public function __destruct()
9    {
10        gc_collect_cycles();
11    }
12
13    public function getB()
14    {
15        $this->data['foo'] = new B($this);
16        $this->data['bar'] = new B($this);
17        // Return either of the above
18        return $this->data['foo'];
19    }
20}
21
22class B
23{
24    public function __construct(public $A) {}
25
26    public function __destruct()
27    {
28    }
29}
30
31for ($i = 0; $i < 2; $i++)
32{
33    $Aobj = new A;
34    $Bobj = $Aobj->getB();
35    unset($Bobj);
36    unset($Aobj);
37}
38
39echo "DONE\n";
40?>
41--EXPECT--
42DONE
43