Commit e43d3d10c32 for php
commit e43d3d10c32bec6606c094ba3cef7f8bf494f899
Author: Tomasz Kowalczyk <tomasz@kowalczyk.cc>
Date: Wed Nov 25 15:07:42 2026 +0100
Fix GH-25746: array_column() crashes with JIT when the result for an empty array is modified
Since 5d24c8bd605, array_column() returns the shared immutable empty array for
an empty input. The stub still declared @refcount 1, which lets function JIT
and tracing JIT modify the result in place and crash. Drop the annotation.
Closes GH-25748.
diff --git a/NEWS b/NEWS
index 04b58161157..417809599fe 100644
--- a/NEWS
+++ b/NEWS
@@ -252,6 +252,8 @@ PHP NEWS
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)
+ . Fixed bug GH-25746 (array_column() crashes with JIT when the result for an
+ empty array is modified). (Tomasz Kowalczyk)
- 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 8a7bc2dfcf3..d09d0631868 100644
--- a/Zend/Optimizer/zend_func_infos.h
+++ b/Zend/Optimizer/zend_func_infos.h
@@ -391,7 +391,6 @@ static const func_info_t func_infos[] = {
FN("array_keys", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
FN("array_values", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
F1("array_count_values", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG),
- F1("array_column", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
F1("array_reverse", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
F1("array_flip", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING),
F1("array_change_key_case", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF),
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php
index 2733e94468d..e354ee995b2 100644
--- a/ext/standard/basic_functions.stub.php
+++ b/ext/standard/basic_functions.stub.php
@@ -1741,7 +1741,6 @@ function array_count_values(array $array): array {}
/**
* @compile-time-eval
- * @refcount 1
*/
function array_column(array $array, int|string|null $column_key, int|string|null $index_key = null): array {}
diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h
index 9bc96ad43c6..163c26be4ad 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 ea0ca1d6f1e..2a22968e8fb 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/array/gh25746.phpt b/ext/standard/tests/array/gh25746.phpt
new file mode 100644
index 00000000000..02d88576dff
--- /dev/null
+++ b/ext/standard/tests/array/gh25746.phpt
@@ -0,0 +1,24 @@
+--TEST--
+GH-25746: array_column() crashes with JIT when the result for an empty array is modified
+--EXTENSIONS--
+opcache
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.jit=function
+opcache.jit_buffer_size=64M
+opcache.file_update_protection=0
+--FILE--
+<?php
+function test(array $rows) {
+ $ids = array_column($rows, "id");
+ $ids[] = 1;
+ return $ids;
+}
+var_dump(test([]));
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ int(1)
+}