Commit 195a8fd2db3 for php
commit 195a8fd2db306dbec498500c59e3ffd26cafacdc
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Thu Nov 19 11:21:10 2026 -0500
ext/standard: Fix refcount info for set_include_path()
Since cd753007ce1, set_include_path() returns the previous include_path INI
string with an added reference instead of a copy. That string is the one
passed to the earlier set_include_path() call, so the result can be shared
with the caller's variable, with values read through get_include_path() or
ini_get(), and with the INI entry itself. The stub still declared
@refcount 1, which lets function JIT and hot tracing JIT destroy a discarded
result without checking its refcount and free a string that is still in use.
Drop the annotation, as ecb90c1db7e did for get_include_path(). The other
@refcount 1 functions touched by cd753007ce1 still return fresh values.
Closes GH-25607
diff --git a/NEWS b/NEWS
index 2b1d5c5c1d4..96ce37007b4 100644
--- a/NEWS
+++ b/NEWS
@@ -192,6 +192,8 @@ PHP NEWS
value is expected. (Jorg Sowa)
. Fixed getimagesize() reporting wrapped dimensions for XBM images with
out-of-range width or height. (Ilia Alshanetsky)
+ . Fixed JIT freeing the previous include_path returned by set_include_path()
+ while it is still in use. (Ilia Alshanetsky)
- Streams:
. Fixed in-place URL decoding of interned strings in the HTTP and FTP
diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h
index a8c94cf891c..102da2fd042 100644
--- a/Zend/Optimizer/zend_func_infos.h
+++ b/Zend/Optimizer/zend_func_infos.h
@@ -422,7 +422,6 @@ static const func_info_t func_infos[] = {
F1("php_strip_whitespace", MAY_BE_STRING),
F1("highlight_string", MAY_BE_STRING|MAY_BE_TRUE),
F1("ini_get_all", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_ARRAY_OF_NULL|MAY_BE_FALSE),
- F1("set_include_path", MAY_BE_STRING|MAY_BE_FALSE),
F1("print_r", MAY_BE_STRING|MAY_BE_TRUE),
#if defined(HAVE_GETSERVBYPORT)
F1("getservbyport", MAY_BE_STRING|MAY_BE_FALSE),
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 4b455ec331b..2733e94468d 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -2031,7 +2031,6 @@ function ini_restore(string $option): void {}
function ini_parse_quantity(string $shorthand): int {}
-/** @refcount 1 */
function set_include_path(string $include_path): string|false {}
function get_include_path(): string|false {}
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index b770a1e8684..9bc96ad43c6 100644
Binary files a/ext/standard/basic_functions_arginfo.h and b/ext/standard/basic_functions_arginfo.h differ
diff --git a/ext/standard/basic_functions_decl.h b/ext/standard/basic_functions_decl.h
index aab4e4b5f09..ea0ca1d6f1e 100644
Binary files a/ext/standard/basic_functions_decl.h and b/ext/standard/basic_functions_decl.h differ
diff --git a/ext/standard/tests/general_functions/set_include_path_jit_refcount.phpt b/ext/standard/tests/general_functions/set_include_path_jit_refcount.phpt
new file mode 100644
index 00000000000..8c41df940df
--- /dev/null
+++ b/ext/standard/tests/general_functions/set_include_path_jit_refcount.phpt
@@ -0,0 +1,32 @@
+--TEST--
+set_include_path() result is not freed while the old include_path is still referenced under JIT
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.jit_buffer_size=64M
+opcache.file_update_protection=0
+--ENV--
+INC_PATH=inc_path_a
+--FILE--
+<?php
+$path = getenv("INC_PATH");
+set_include_path($path);
+set_include_path("inc_path_b");
+echo "argument: ";
+var_dump($path);
+
+set_include_path(getenv("INC_PATH"));
+$old = get_include_path();
+set_include_path("inc_path_b");
+echo "old include_path: ";
+var_dump($old);
+echo "new include_path: ";
+var_dump(get_include_path());
+?>
+--EXPECT--
+argument: string(10) "inc_path_a"
+old include_path: string(10) "inc_path_a"
+new include_path: string(10) "inc_path_b"