[php-src] master: Fix GH-25746: array_column() crashes with JIT when the result for an empty array is modified
| From: | Tomasz Kowalczyk via ndossche | Date: | Wed, 25 Nov 2026 18:20:13 +0000 |
| Subject: | [php-src] master: Fix GH-25746: array_column() crashes with JIT when the result for an empty array is modified | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144176@lists.php.net to get a copy of this message | ||
Author: Tomasz Kowalczyk (thunderer)
Committer: ndossche (ndossche)
Date: 2026-11-25T19:18:58+01:00
Commit: https://github.com/php/php-src/commit/e43d3d10c32bec6606c094ba3cef7f8bf494f899
Raw diff: https://github.com/php/php-src/commit/e43d3d10c32bec6606c094ba3cef7f8bf494f899.diff
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.
Changed paths:
A ext/standard/tests/array/gh25746.phpt
M NEWS
M Zend/Optimizer/zend_func_infos.h
M ext/standard/basic_functions.stub.php
M ext/standard/basic_functions_arginfo.h
M ext/standard/basic_functions_decl.h
Diff:
diff --git a/NEWS b/NEWS
index 04b58161157b..417809599fe1 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 8a7bc2dfcf3f..d09d06318685 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 2733e94468df..e354ee995b2c 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 9bc96ad43c65..163c26be4ad5 100644
--- a/ext/standard/basic_functions_arginfo.h
+++ b/ext/standard/basic_functions_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit basic_functions.stub.php instead.
- * Stub hash: cf186afde03090331d3037c23e49e75fe2670ff5
+ * Stub hash: 3d3771e5df903f7c3e7f9dff8f66e63300e20709
* Has decl header: yes */
#include "zend_attributes.h"
diff --git a/ext/standard/basic_functions_decl.h b/ext/standard/basic_functions_decl.h
index ea0ca1d6f1ef..2a22968e8fbc 100644
--- a/ext/standard/basic_functions_decl.h
+++ b/ext/standard/basic_functions_decl.h
@@ -1,8 +1,8 @@
/* This is a generated file, edit basic_functions.stub.php instead.
- * Stub hash: cf186afde03090331d3037c23e49e75fe2670ff5 */
+ * Stub hash: 3d3771e5df903f7c3e7f9dff8f66e63300e20709 */
-#ifndef ZEND_BASIC_FUNCTIONS_DECL_cf186afde03090331d3037c23e49e75fe2670ff5_H
-#define ZEND_BASIC_FUNCTIONS_DECL_cf186afde03090331d3037c23e49e75fe2670ff5_H
+#ifndef ZEND_BASIC_FUNCTIONS_DECL_3d3771e5df903f7c3e7f9dff8f66e63300e20709_H
+#define ZEND_BASIC_FUNCTIONS_DECL_3d3771e5df903f7c3e7f9dff8f66e63300e20709_H
typedef enum zend_enum_SortDirection {
ZEND_ENUM_SortDirection_Ascending = 1,
@@ -20,4 +20,4 @@ typedef enum zend_enum_RoundingMode {
ZEND_ENUM_RoundingMode_PositiveInfinity = 8,
} zend_enum_RoundingMode;
-#endif /* ZEND_BASIC_FUNCTIONS_DECL_cf186afde03090331d3037c23e49e75fe2670ff5_H */
+#endif /* ZEND_BASIC_FUNCTIONS_DECL_3d3771e5df903f7c3e7f9dff8f66e63300e20709_H */
diff --git a/ext/standard/tests/array/gh25746.phpt b/ext/standard/tests/array/gh25746.phpt
new file mode 100644
index 000000000000..02d88576dfff
--- /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)
+}