Skip to content

Commit 051ff33

Browse files
committed
Fix bug #81272: Fix func info for functions returning EMPTY_ARRAY
The empty array has refcount > 1, so we should indicate this in func info. In most cases this renders the func info redundant, so drop it entirely.
1 parent 18abfcb commit 051ff33

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818
enabled). (Dmitry)
1919
. Fixed bug #81206 (Multiple PHP processes crash with JIT enabled). (cmb,
2020
Nikita)
21+
. Fixed bug #81272 (Segfault in var[] after array_slice with JIT). (Nikita)
2122

2223
- Standard:
2324
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,11 @@ static const func_info_t func_infos[] = {
368368
FN("min", UNKNOWN_INFO),
369369
FN("max", UNKNOWN_INFO),
370370
F1("compact", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
371-
F1("array_fill", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
371+
FN("array_fill", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
372372
F1("array_fill_keys", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
373373
FC("range", zend_range_info),
374374
FN("array_pop", UNKNOWN_INFO),
375375
FN("array_shift", UNKNOWN_INFO),
376-
F1("array_splice", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
377-
F1("array_slice", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
378376
F1("array_replace", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
379377
F1("array_replace_recursive", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
380378
FN("array_keys", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_LONG | MAY_BE_ARRAY_OF_STRING),
@@ -400,9 +398,6 @@ static const func_info_t func_infos[] = {
400398
F1("array_udiff_assoc", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
401399
F1("array_diff_uassoc", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
402400
F1("array_udiff_uassoc", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
403-
F1("array_filter", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
404-
F1("array_chunk", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
405-
F1("array_combine", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_REF | MAY_BE_ARRAY_OF_ANY),
406401
F1("str_rot13", MAY_BE_STRING),
407402
F1("stream_get_filters", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_STRING),
408403
F1("stream_bucket_make_writeable", MAY_BE_NULL | MAY_BE_OBJECT),
@@ -563,7 +558,7 @@ static const func_info_t func_infos[] = {
563558

564559
/* ext/json */
565560
F1("json_encode", MAY_BE_FALSE | MAY_BE_STRING),
566-
F1("json_decode", MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
561+
FN("json_decode", MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY),
567562
F1("json_last_error_msg", MAY_BE_STRING),
568563

569564
/* ext/xml */

ext/opcache/tests/bug81272.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #81272: Segfault in var[] after array_slice with JIT
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit_buffer_size=16M
7+
opcache.jit=function
8+
--FILE--
9+
<?php
10+
11+
function test() {
12+
$newPages = array_slice([], 0, 0);
13+
$newPages[] = null;
14+
}
15+
16+
test();
17+
18+
?>
19+
===DONE===
20+
--EXPECT--
21+
===DONE===

0 commit comments

Comments
 (0)