1--TEST-- 2GH-13612 (Corrupted memory in destructor with weak references) 3--FILE-- 4<?php 5 6class WeakAnalysingMapRepro 7{ 8 public array $destroyed = []; 9 public array $ownerDestructorHandlers = []; 10 11 public function __construct() 12 { 13 $handler = new class($this) { 14 private \WeakReference $weakAnalysingMap; 15 16 public function __construct(WeakAnalysingMapRepro $analysingMap) 17 { 18 $this->weakAnalysingMap = \WeakReference::create($analysingMap); 19 } 20 21 public function __destruct() 22 { 23 var_dump($this->weakAnalysingMap->get()); 24 } 25 }; 26 27 $this->destroyed[] = 1; 28 $this->ownerDestructorHandlers[] = $handler; 29 } 30} 31 32new WeakAnalysingMapRepro(); 33 34echo "Done\n"; 35 36?> 37--EXPECT-- 38NULL 39Done 40