1--TEST-- 2GH-8409: Error in socket creation when error handler does not clean persistent connection 3--FILE-- 4<?php 5set_error_handler(function (int $errno, string $errstring): never { 6 throw new Exception($errstring); 7}); 8 9register_shutdown_function(function (): void { 10 foreach (get_resources() as $res) { 11 if (get_resource_type($res) === 'persistent stream') { 12 echo "ERROR: persistent stream not closed\n"; 13 return; 14 } 15 } 16 echo "OK: persistent stream closed\n"; 17}); 18 19stream_socket_client('tcp://9999.9999.9999.9999:9999', $error_code, $error_message, 0.2, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT); 20 21echo "ERROR: this should not be visible\n"; 22?> 23--EXPECTF-- 24Fatal error: Uncaught Exception: stream_socket_client(): %s in %sgh8409.php:%d 25Stack trace: 26#0 [internal function]: {closure:%s:%d}(2, 'stream_socket_c...', '%s', %d) 27#1 %s(%d): stream_socket_client('tcp://9999.9999...', 0, '', 0.2, 5) 28#2 {main} 29 thrown in %s on line %d 30OK: persistent stream closed 31