xref: /PHP-8.3/Zend/tests/bug78379.phpt (revision 902d6439)
1--TEST--
2Bug #78379 (Cast to object confuses GC, causes crash)
3--FILE--
4<?php
5class C {
6    public $p;
7    public function __construct() {
8        $this->p = (object)["x" => [1]];
9    }
10}
11#[AllowDynamicProperties]
12class E {
13}
14$e = new E;
15$e->f = new E;
16$e->f->e = $e;
17$e->a = new C;
18$e = null;
19gc_collect_cycles();
20var_dump(new C);
21?>
22--EXPECTF--
23object(C)#%d (1) {
24  ["p"]=>
25  object(stdClass)#%d (1) {
26    ["x"]=>
27    array(1) {
28      [0]=>
29      int(1)
30    }
31  }
32}
33