[php-src] master: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Ilia Alshanetsky | Date: | Thu, 19 Nov 2026 23:51:01 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143944@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-11-19T18:44:50-05:00
Commit: https://github.com/php/php-src/commit/c2f6aa93e7cd49dec21cdfc773e3cf6e16cecfdb
Raw diff: https://github.com/php/php-src/commit/c2f6aa93e7cd49dec21cdfc773e3cf6e16cecfdb.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
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 19895e9242c1..1e9d0c7e053c 100644
--- a/NEWS
+++ b/NEWS
@@ -71,6 +71,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-25165 (Tracing JIT loops forever once opcache.jit_buffer_size
diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h
index ffef7066efbf..be2a0c3639b6 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 af9c5cbb93ea..02e3c36d0295 100644
--- a/ext/mbstring/mbstring.stub.php
+++ b/ext/mbstring/mbstring.stub.php
@@ -81,7 +81,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 {}
@@ -159,7 +158,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 230dddf96941..3fa13bd7bd9e 100644
--- a/ext/mbstring/mbstring_arginfo.h
+++ b/ext/mbstring/mbstring_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 03c07f68bea7d7b96e6dc11f180f45663b859ed3 */
+ * Stub hash: 8cfae3e99cc4ac5b55882bb962091426bb2847ca */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mb_language, 0, 0, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, language, IS_STRING, 1, "null")
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)