[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Ilia Alshanetsky | Date: | Thu, 19 Nov 2026 23:51:04 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143945@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-11-19T18:44:54-05:00
Commit: https://github.com/php/php-src/commit/fec70440dd88b51bfe7573d38b9dd635883065c3
Raw diff: https://github.com/php/php-src/commit/fec70440dd88b51bfe7573d38b9dd635883065c3.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/mbstring: Fix refcount info for mb_encode_mimeheader(), mb_output_handler()
Changed paths:
A ext/mbstring/tests/jit_returned_input_refcount.phpt
M NEWS
M Zend/Optimizer/zend_func_infos.h
M ext/mbstring/mbstring.stub.php
M ext/mbstring/mbstring_arginfo.h
Diff:
diff --git a/NEWS b/NEWS
index 96ce37007b48..f294f129b637 100644
--- a/NEWS
+++ b/NEWS
@@ -84,6 +84,8 @@ PHP NEWS
- MBString:
. Fixed stack overflow in mb_check_encoding() and mb_convert_encoding() with
deeply nested arrays. (Eyüp Can Akman)
+ . Fixed the JIT freeing the string returned by mb_encode_mimeheader() or
+ mb_output_handler() while it is still in use. (Ilia Alshanetsky)
- Opcache:
. Fixed bug GH-22216 (spurious opcache.memory_consumption warning on each new
diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h
index 102da2fd0426..8a7bc2dfcf3f 100644
--- a/Zend/Optimizer/zend_func_infos.h
+++ b/Zend/Optimizer/zend_func_infos.h
@@ -206,7 +206,6 @@ static const func_info_t func_infos[] = {
F1("mb_detect_order",
MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_TRUE),
F1("mb_substitute_character", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_BOOL),
F1("mb_preferred_mime_name", MAY_BE_STRING|MAY_BE_FALSE),
- F1("mb_output_handler", MAY_BE_STRING),
F1("mb_strstr", MAY_BE_STRING|MAY_BE_FALSE),
F1("mb_strrchr", MAY_BE_STRING|MAY_BE_FALSE),
F1("mb_stristr", MAY_BE_STRING|MAY_BE_FALSE),
@@ -220,7 +219,6 @@ static const func_info_t func_infos[] = {
F1("mb_detect_encoding", MAY_BE_STRING|MAY_BE_FALSE),
FN("mb_list_encodings", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("mb_encoding_aliases", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
- F1("mb_encode_mimeheader", MAY_BE_STRING),
F1("mb_decode_mimeheader", MAY_BE_STRING),
F1("mb_convert_kana", MAY_BE_STRING),
F1("mb_convert_variables", MAY_BE_STRING|MAY_BE_FALSE),
diff --git a/ext/mbstring/mbstring.stub.php b/ext/mbstring/mbstring.stub.php
index 109a3ad564d8..9f07da80d32c 100644
--- a/ext/mbstring/mbstring.stub.php
+++ b/ext/mbstring/mbstring.stub.php
@@ -82,7 +82,6 @@ function mb_preferred_mime_name(string $encoding): string|false {}
/** @param array $result */
function mb_parse_str(string $string, &$result): bool {}
-/** @refcount 1 */
function mb_output_handler(string $string, int $status): string {}
function mb_str_split(string $string, int $length = 1, ?string $encoding = null): array {}
@@ -160,7 +159,6 @@ function mb_list_encodings(): array {}
*/
function mb_encoding_aliases(string $encoding): array {}
-/** @refcount 1 */
function mb_encode_mimeheader(string $string, ?string $charset = null, ?string $transfer_encoding =
null, string $newline = "\r\n", int $indent = 0): string {}
/** @refcount 1 */
diff --git a/ext/mbstring/mbstring_arginfo.h b/ext/mbstring/mbstring_arginfo.h
index 593589b66db1..65b97cef07ae 100644
--- a/ext/mbstring/mbstring_arginfo.h
+++ b/ext/mbstring/mbstring_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit mbstring.stub.php instead.
- * Stub hash: f02c317efd6814f902ea75c9d222893713546845 */
+ * Stub hash: db95469ee39648ca5f0e67354126f1cb1fdcb21b */
#if defined(HAVE_MBREGEX)
#include "zend_attributes.h"
diff --git a/ext/mbstring/tests/jit_returned_input_refcount.phpt
b/ext/mbstring/tests/jit_returned_input_refcount.phpt
new file mode 100644
index 000000000000..a01954f7bfe4
--- /dev/null
+++ b/ext/mbstring/tests/jit_returned_input_refcount.phpt
@@ -0,0 +1,30 @@
+--TEST--
+mb_encode_mimeheader() and mb_output_handler() returning their input string under function JIT
+--EXTENSIONS--
+mbstring
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.jit_buffer_size=64M
+opcache.file_update_protection=0
+--FILE--
+<?php
+$s = str_repeat("a", mt_rand(3, 3));
+mb_encode_mimeheader($s);
+mb_http_output("UTF-8");
+mb_output_handler($s, 0);
+mb_http_output("pass");
+mb_output_handler($s, 0);
+echo "input after calls: ";
+var_dump($s);
+echo "mb_encode_mimeheader() returns input: ";
+var_dump(mb_encode_mimeheader($s) === $s);
+echo "mb_output_handler() returns input: ";
+var_dump(mb_output_handler($s, 0) === $s);
+?>
+--EXPECT--
+input after calls: string(3) "aaa"
+mb_encode_mimeheader() returns input: bool(true)
+mb_output_handler() returns input: bool(true)