[php-src] master: Merge remote-tracking branch 'origin/PHP-8.6'

From: Date: Mon, 28 Sep 2026 13:40:10 +0000
Subject: [php-src] master: Merge remote-tracking branch 'origin/PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141624@lists.php.net to get a copy of this message
Author: Levi Morrison (morrisonlevi) Date: 2026-09-28T07:39:22-06:00 Commit: https://github.com/php/php-src/commit/14a2eab5029caf9556f25e684a27cfd38816815d Raw diff: https://github.com/php/php-src/commit/14a2eab5029caf9556f25e684a27cfd38816815d.diff Merge remote-tracking branch 'origin/PHP-8.6' # Conflicts: # NEWS Changed paths: A ext/standard/tests/streams/persistent_stream_context_shutdown.phpt M NEWS M ext/standard/basic_functions.c M main/php_streams.h M main/streams/streams.c Diff: diff --git a/NEWS b/NEWS index a6e87d987ca1..9d2ff90ed7f9 100644 --- a/NEWS +++ b/NEWS @@ -14,12 +14,80 @@ PHP NEWS . Fixed Collator attribute and strength methods not rejecting an unconstructed Collator. (Ilia Alshanetsky) +- Lexbor: + . Merge patches lexbor/lexbor@8a14bc0 and lexbor/lexbor@f67ce4b, fixing a + heap buffer overflow in :lexbor-contains() parsing and buffer overflows + in malformed decode replay. (alexandre-daubois) + +- MBString: + . Fixed bug GH-23106 (mb_strpos() reads past the end of a haystack ending in + a truncated UTF-8 sequence). (Lazizbek Ergashev) + . Updated Unicode data tables to Unicode 18.0 (Yuya Hamada) + . Fixed mbstring functions emitting surrogates in UTF-8 output and flagging + it as valid UTF-8. (Nicolas Grekas) + +- MySQLi: + . Fix GH-22854: Fixed failed assertion when accessing mysqli property after + failed reconnection. (Kamil Tekiela) + +- Opcache: + . Fixed bug GH-23693 (Tracing JIT produces wrong results for a guard on a + loop-invariant addition). (Ilia Alshanetsky) + . Fixed OSS-Fuzz #545352966 (default value AST of an SHM-persisted partial). + (ndossche) + +- PDO: + . Fixed PDOStatement::getColumnMeta() reading out of bounds for an invalid + column index. (Ilia Alshanetsky) + . Fixed PDOStatement::bindColumn() registering a binding for a column name + that is not in the result set. (Ilia Alshanetsky) + +- PGSQL: + . Fixed pg_lo_write() rejecting data containing null bytes. (Ilia Alshanetsky) + +- Posix: + . Reverted the validity check on the flags argument of posix_access(). + (David Carlier) + +- Readline: + . Fixed a heap over-read in the interactive shell prompt when cli.prompt is + set to an empty string. (Ilia Alshanetsky) + +- Session: + . Fixed session_start() continuing after a failed create_sid() when + session.use_strict_mode rejects the supplied ID. (Ilia Alshanetsky) + . Fixed exceptions from user-defined create_sid() handlers being replaced + by return-value validation errors. (Ilia Alshanetsky) + - SOAP: . Fixed the SOAP client accepting a response body shorter than its Content-Length and reusing the connection. (Ilia Alshanetsky) +- SPL: + . Fixed bug GH-23385 (SplDoublyLinkedList::serialize() use-after-free when + __serialize() removes an element). (David Carlier) + +- SQLite: + . Fixed a crash when SQLite3::close() is called from a userland callback. + (Ilia Alshanetsky) + - Standard: + . Fixed bug #60110 (fclose(), file_put_contents(), copy() do not return false + properly). (Jakub Zelenka, Ilija Tovilo) + . Fixed three Windows-only proc_open() defects: an uninitialized + PROCESS_INFORMATION, an indeterminate comspec pointer after a failed + lookup, and an unchecked CreateFileA() failure. (Ilia Alshanetsky) + . Fix persistent stream context lifetime during shutdown (Levi Morrison) + . Fixed bug GH-23780 (unserialize('') fails silently). (timwolla) . Improved performance of array_splice() when inserting without removing elements. (mehmetcansahin) +- URI: + . Fix casing of enum cases in UriHostType and UrlHostType to match the RFC + and PHP’s naming policy. (timwolla) + +- Zlib: + . Fixed inflate_init() dropping the preset dictionary for raw streams with + a non-default window. (Ilia Alshanetsky) + <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 3699564169b5..1665feac37df 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -155,7 +155,9 @@ zend_module_entry basic_functions_module = { /* {{{ */ PHP_RSHUTDOWN(basic), /* request shutdown */ PHP_MINFO(basic), /* extension info */ PHP_STANDARD_VERSION, /* extension version */ - STANDARD_MODULE_PROPERTIES + NO_MODULE_GLOBALS, + ZEND_MODULE_POST_ZEND_DEACTIVATE_N(streams), + STANDARD_MODULE_PROPERTIES_EX }; /* }}} */ @@ -463,7 +465,6 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ #endif BASIC_RSHUTDOWN_SUBMODULE(assert) BASIC_RSHUTDOWN_SUBMODULE(url_scanner_ex) - BASIC_RSHUTDOWN_SUBMODULE(streams) #ifdef PHP_WIN32 BASIC_RSHUTDOWN_SUBMODULE(win32_core_globals) #endif diff --git a/ext/standard/tests/streams/persistent_stream_context_shutdown.phpt b/ext/standard/tests/streams/persistent_stream_context_shutdown.phpt new file mode 100644 index 000000000000..34a0b42a9f45 --- /dev/null +++ b/ext/standard/tests/streams/persistent_stream_context_shutdown.phpt @@ -0,0 +1,63 @@ +--TEST-- +Persistent stream contexts created during resource shutdown are detached +--FILE-- +<?php + +if (($argv[1] ?? null) !== 'child') { + // Wait for the trigger's final status because the crash occurs after stdout closes. + $process = proc_open( + [PHP_BINARY, '-n', __FILE__, 'child'], + [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ], + $pipes, + ); + fclose($pipes[0]); + stream_get_contents($pipes[1]); + fclose($pipes[1]); + stream_get_contents($pipes[2]); + fclose($pipes[2]); + var_dump(proc_close($process)); + return; +} + +final class LateContextWrapper +{ + public $context; + private string $address; + + public function stream_open($path, $mode, $options, &$opened_path): bool + { + $this->address = substr($path, strlen('late-context://')); + return true; + } + + public function stream_close(): void + { + $context = stream_context_create([ + 'socket' => ['tcp_nodelay' => true], + ]); + stream_socket_client( + $this->address, + $errno, + $error, + 1, + STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, + $context, + ); + } +} + +$server = stream_socket_server('tcp://127.0.0.1:0', $errno, $error); +if (!$server) { + die("server failed: $error ($errno)\n"); +} + +stream_wrapper_register('late-context', LateContextWrapper::class); +$trigger = fopen('late-context://tcp://' . stream_socket_get_name($server, false), 'r'); + +?> +--EXPECT-- +int(0) diff --git a/main/php_streams.h b/main/php_streams.h index 69bd996fea4f..0111a6a78413 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -610,7 +610,7 @@ END_EXTERN_C() void php_init_stream_wrappers(int module_number); void php_shutdown_stream_wrappers(int module_number); void php_shutdown_stream_hashes(void); -PHP_RSHUTDOWN_FUNCTION(streams); +ZEND_MODULE_POST_ZEND_DEACTIVATE_D(streams); BEGIN_EXTERN_C() PHPAPI zend_result php_register_url_stream_wrapper(const char *protocol, const php_stream_wrapper *wrapper); diff --git a/main/streams/streams.c b/main/streams/streams.c index 0862dc7081e5..ae2d4b910627 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -80,17 +80,14 @@ static int forget_persistent_resource_id_numbers(zval *el) fprintf(stderr, "forget_persistent: %s:%p\n", stream->ops->label, stream); #endif + /* Request resources have been destroyed; clear their stale pointers. */ stream->res = NULL; - - if (stream->ctx) { - zend_list_delete(stream->ctx); - stream->ctx = NULL; - } + stream->ctx = NULL; return 0; } -PHP_RSHUTDOWN_FUNCTION(streams) +ZEND_MODULE_POST_ZEND_DEACTIVATE_D(streams) { zval *el;

« previous php.cvs (#141624) next »