Tracing JIT: segfault on $f($arr[k]) when $f alternates between by-value and by-reference functions
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Start with zend_jit_trace.c and zend_jit_ir.c, following the reported INIT_DYNAMIC_CALL, FETCH_DIM_FUNC_ARG, and ZEND_SEND_FUNC_ARG paths; compare the DIM handling with the object fetch guard mentioned in the issue. Run the supplied reproducer with tracing JIT enabled and with JIT off to confirm the failure. Done means the JIT run exits normally while preserving the expected warnings.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
With the tracing JIT, a dynamic call $f($arr[k]) where $f alternates between a by-value and a by-reference function crashes.
<?php
function byval($a) { return (int)$a; }
function byref(&$a) { return (int)$a; }
$fns = ["byval", "byref"]; $arr = [];
for ($i = 0; $i < 120; $i++) { $f = $fns[$i % 2]; $f($arr[1]); $f($arr[0]); }
php -n -d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.file_update_protection=0 -d opcache.jit_buffer_size=64M -d opcache.jit=tracing -d opcache.jit_hot_loop=1 -d opcache.jit_hot_func=1 -d opcache.jit_hot_return=1 -d opcache.jit_hot_side_exit=1 -d opcache.jit_max_polymorphic_calls=0 reduced.php
Debug build:
Warning: Undefined array key 1 in reduced.php on line 5
Warning: Undefined array key 0 in reduced.php on line 5
php: Zend/zend_operators.c:1016: zval_get_long_func: Assertion `0' failed.
Release build: the same two warnings, then SIGSEGV (exit 139).
With opcache.jit=off the script only prints the two warnings and exits normally, so I expected the same under the JIT. jit_max_polymorphic_calls=0 is not required: with the default value, a variant with five callees (four by-value, one by-ref) and a defined $arr = [5, 6] crashes the same way. The hot counters of 1 are needed to form the traces in a short script.
It reproduces at 9253b03bef3f7cb96ac2594c23382b0ba5ab6e19 (latest upstream when checked): the debug build hits the assertion above, the release build segfaults (rc 139).
Looks like the megamorphic INIT_DYNAMIC_CALL (call->func unknown) makes zend_jit_trace.c skip the specialised FETCH_DIM_FUNC_ARG, but zend_jit_send_var (zend_jit_ir.c, ZEND_SEND_FUNC_ARG) still compiles the by-ref branch using the recorded type of the fetched value, which does not include MAY_BE_INDIRECT. ZEND_FETCH_OBJ_FUNC_ARG has a zend_jit_func_arg_by_ref_guard for this case and the DIM variant does not. This is from reading jit_debug trace output, not confirmed in a debugger. Open PR #18392 (reworks EX(call) handling in the call/send path) may be related; I did not test it, its diff does not apply on the latest commit.
I can send a patch if that helps.
Found with an LLM-based testing tool; I used Claude to reduce it and look for the cause.
- Ngôn ngữ chính
- C
- Star
- 40.7k
- Fork
- 8.3k
- Merge trung bình
- 2 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 147
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của php/php-src
-
sapi/fpm/tests/tester.inc can send SIGUSR2 to pid 0, killing run-tests.phpCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởBug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
zend_set_local_var() overwrites existing compiled variable (CV) zval without calling zval_ptr_dtor()Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởBug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Case-insensitive substr_compare, ksort, krsort are still locale-dependentCó thể đã có người làm @lazerg đã nhận 4 ngày trước. Đang mởBug Extension: standard Status: Verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
php/php-src#24552 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
master: part of the mbstring bailout fix got lost in a mergeCó thể đã có người làm @lazerg đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
CVE-2026-111497Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
fink/fink-distributions#1322 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
openvehicles/Open-Vehicle-Monitoring-System-3#1563 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ONLYOFFICE/DesktopEditors#2533 ·