xref: /PHP-8.2/ext/spl/tests/gh14687.phpt (revision eeec0939)
1--TEST--
2GH-14687 segfault on debugging SplObjectStorage instance after __destruct.
3--CREDITS--
4YuanchengJiang
5--EXTENSIONS--
6phar
7--INI--
8phar.require_hash=0
9phar.readonly=0
10--FILE--
11<?php
12$fname = __DIR__ . '/gh14687.phar.zip';
13$phar = new Phar($fname);
14class HasDestructor {
15  public function __destruct() {
16    var_dump($GLOBALS['s']);
17  }
18}
19$s = new SplObjectStorage();
20$s[$phar] = new HasDestructor();
21register_shutdown_function(function() {
22	global $s;
23});
24?>
25--CLEAN--
26<?php
27@unlink(__DIR__ . '/gh14687.phar.zip');
28?>
29--EXPECT--
30object(SplObjectStorage)#2 (1) {
31  ["storage":"SplObjectStorage":private]=>
32  array(1) {
33    [0]=>
34    array(2) {
35      ["obj"]=>
36      object(Phar)#1 (3) {
37        ["pathName":"SplFileInfo":private]=>
38        string(0) ""
39        ["glob":"DirectoryIterator":private]=>
40        bool(false)
41        ["subPathName":"RecursiveDirectoryIterator":private]=>
42        string(0) ""
43      }
44      ["inf"]=>
45      object(HasDestructor)#3 (0) {
46      }
47    }
48  }
49}
50