xref: /PHP-8.3/Zend/tests/bug71859.phpt (revision 902d6439)
1--TEST--
2Bug #71859 (zend_objects_store_call_destructors operates on realloced memory, crashing)
3--FILE--
4<?php
5class constructs_in_destructor {
6  public $a;
7  public function __destruct() {
8    //We are now in zend_objects_store_call_destructors
9    //This causes a realloc in zend_objects_store_put
10    for ($i = 0; $i < 10000; ++$i) {
11      $GLOBALS["a$i"] = new stdClass;
12    }
13    //Returns to zend_objects_store_call_destructors, to access freed memory.
14  }
15}
16
17$a = new constructs_in_destructor;
18//Create cycle so destructors are ran only in zend_objects_store_call_destructors
19$a->a = $a;
20
21// Create some objects so zend_objects_store_call_destructors has something
22// to do after constructs_in_destructor is destroyed.
23for ($i = 0; $i < 200; ++$i) {
24  $GLOBALS["b$i"] = new stdClass;
25}
26?>
27okey
28--EXPECT--
29okey
30