[php-src] PR #25828: Fix JIT freeing a persistent stream returned by stream_socket_client()

From: Date: Fri, 27 Nov 2026 09:42:22 +0000
Subject: [php-src] PR #25828: Fix JIT freeing a persistent stream returned by stream_socket_client()
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41100@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25828 Author: lacatoire With STREAM_CLIENT_PERSISTENT, a second stream_socket_client() call for the same address returns the already registered resource with an added reference, but the stub declares @refcount 1. Function JIT and hot tracing JIT then destroy a discarded result without checking its refcount, closing a stream that is still in use and corrupting memory. The annotation is dropped, as pfsockopen() already does. ### To reproduce Run with opcache.enable_cli=1 and opcache.jit=function. ```php <?php function connect_twice(string $address): void { $keep = stream_socket_client("tcp://$address", $errno, $errstr, 1, STREAM_CLIENT_PERSISTENT | STREAM_CLIENT_CONNECT); stream_socket_client("tcp://$address", $errno, $errstr, 1, STREAM_CLIENT_PERSISTENT | STREAM_CLIENT_CONNECT); var_dump(is_resource($keep)); } $server = stream_socket_server('tcp://127.0.0.1:0'); connect_twice(stream_socket_get_name($server, false)); ``` Before (8.4.28, 8.5.13): ``` bool(false) Segmentation fault (core dumped) ``` After: ``` bool(true) ``` With the default tracing JIT, calling the function in a hot loop ends in zend_mm_heap corrupted.

« previous php.git-pulls (#41100) next »