-
Notifications
You must be signed in to change notification settings - Fork 8k
Possible JIT regression on PHP +8.4 #20690
Copy link
Copy link
Closed
Labels
Description
Description
I noticed that when I run a simple php -v under Valgrind with the JIT enabled it emits warnings about conditional jumps on uninitialized values coming from the IR subsystem of the JIT.
This execution never returns an error (JIT disabled) for any version of PHP from 8.1 to 8.5 inclusive:
$ export USE_ZEND_ALLOC=0
$ export ZEND_DONT_UNLOAD_MODULES=1
$ valgrind --tool=memcheck \
--track-origins=yes --num-callers=50 --undef-value-errors=yes \
--error-exitcode=1 \
php -n \
-d zend_extension=opcache \
-d opcache.enable_cli=1 \
-d opcache.jit=disable \
-d opcache.jit_buffer_size=256M \
-vWhereas this one (JIT enabled in tracing mode) emits the following warnings on PHP 8.4 and 8.5:
$ export USE_ZEND_ALLOC=0
$ export ZEND_DONT_UNLOAD_MODULES=1
$ valgrind --tool=memcheck \
--track-origins=yes --num-callers=50 --undef-value-errors=yes \
--error-exitcode=1 \
php -n \
-d zend_extension=opcache \
-d opcache.enable_cli=1 \
-d opcache.jit=tracing \
-d opcache.jit_buffer_size=256M \
-v...
==2994==
==2994== Conditional jump or move depends on uninitialised value(s)
==2994== at 0x7E21DA6: ir_sparse_set_in (ir_private.h:526)
==2994== by 0x7E21DA6: _check_successors (ir_gcm.c:190)
==2994== by 0x7E21DA6: ir_split_partially_dead_node (ir_gcm.c:276)
==2994== by 0x7E21DA6: ir_gcm_schedule_late (ir_gcm.c:538)
==2994== by 0x7E22BE5: ir_gcm (ir_gcm.c:715)
==2994== by 0x7E4D520: zend_jit_ir_compile (zend_jit_ir.c:2852)
==2994== by 0x7E51024: zend_jit_setup_stubs (zend_jit_ir.c:2931)
==2994== by 0x7EAC5F4: zend_jit_setup (zend_jit_ir.c:3574)
==2994== by 0x7EAC5F4: zend_jit_startup (zend_jit.c:3697)
==2994== by 0x7DDC0BA: accel_post_startup (ZendAccelerator.c:3306)
==2994== by 0x53AAC6: zend_post_startup (zend.c:1105)
==2994== by 0x3CBF5D: php_module_startup (main.c:2326)
==2994== by 0x240859: main (php_cli.c:1277)
==2994== Uninitialised value was created by a heap allocation
==2994== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2994== by 0x437E54: __zend_malloc (zend_alloc.c:3294)
==2994== by 0x7E22B58: ir_sparse_set_init (ir_private.h:500)
==2994== by 0x7E22B58: ir_gcm (ir_gcm.c:704)
==2994== by 0x7E4D520: zend_jit_ir_compile (zend_jit_ir.c:2852)
==2994== by 0x7E51024: zend_jit_setup_stubs (zend_jit_ir.c:2931)
==2994== by 0x7EAC5F4: zend_jit_setup (zend_jit_ir.c:3574)
==2994== by 0x7EAC5F4: zend_jit_startup (zend_jit.c:3697)
==2994== by 0x7DDC0BA: accel_post_startup (ZendAccelerator.c:3306)
==2994== by 0x53AAC6: zend_post_startup (zend.c:1105)
==2994== by 0x3CBF5D: php_module_startup (main.c:2326)
==2994== by 0x240859: main (php_cli.c:1277)
==2994==
==2994== Use of uninitialised value of size 8
==2994== at 0x7E21DA8: ir_sparse_set_in (ir_private.h:526)
==2994== by 0x7E21DA8: _check_successors (ir_gcm.c:190)
==2994== by 0x7E21DA8: ir_split_partially_dead_node (ir_gcm.c:276)
==2994== by 0x7E21DA8: ir_gcm_schedule_late (ir_gcm.c:538)
==2994== by 0x7E22BE5: ir_gcm (ir_gcm.c:715)
==2994== by 0x7E4D520: zend_jit_ir_compile (zend_jit_ir.c:2852)
==2994== by 0x7E51024: zend_jit_setup_stubs (zend_jit_ir.c:2931)
==2994== by 0x7EAC5F4: zend_jit_setup (zend_jit_ir.c:3574)
==2994== by 0x7EAC5F4: zend_jit_startup (zend_jit.c:3697)
==2994== by 0x7DDC0BA: accel_post_startup (ZendAccelerator.c:3306)
==2994== by 0x53AAC6: zend_post_startup (zend.c:1105)
==2994== by 0x3CBF5D: php_module_startup (main.c:2326)
==2994== by 0x240859: main (php_cli.c:1277)
==2994== Uninitialised value was created by a heap allocation
==2994== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2994== by 0x437E54: __zend_malloc (zend_alloc.c:3294)
==2994== by 0x7E22B58: ir_sparse_set_init (ir_private.h:500)
==2994== by 0x7E22B58: ir_gcm (ir_gcm.c:704)
==2994== by 0x7E4D520: zend_jit_ir_compile (zend_jit_ir.c:2852)
==2994== by 0x7E51024: zend_jit_setup_stubs (zend_jit_ir.c:2931)
==2994== by 0x7EAC5F4: zend_jit_setup (zend_jit_ir.c:3574)
==2994== by 0x7EAC5F4: zend_jit_startup (zend_jit.c:3697)
==2994== by 0x7DDC0BA: accel_post_startup (ZendAccelerator.c:3306)
==2994== by 0x53AAC6: zend_post_startup (zend.c:1105)
==2994== by 0x3CBF5D: php_module_startup (main.c:2326)
==2994== by 0x240859: main (php_cli.c:1277)
==2994==
PHP 8.4.15 (cli) (built: Dec 9 2025 12:39:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.15, Copyright (c) Zend Technologies
with Zend OPcache v8.4.15, Copyright (c), by Zend Technologies
==2994== Warning: set address range perms: large range [0x8400000, 0x20400000) (noaccess)
==2994==
==2994== HEAP SUMMARY:
==2994== in use at exit: 85,221 bytes in 1,446 blocks
==2994== total heap usage: 19,546 allocs, 18,100 frees, 5,875,246 bytes allocated
==2994==
==2994== LEAK SUMMARY:
==2994== definitely lost: 0 bytes in 0 blocks
==2994== indirectly lost: 0 bytes in 0 blocks
==2994== possibly lost: 0 bytes in 0 blocks
==2994== still reachable: 85,221 bytes in 1,446 blocks
==2994== suppressed: 0 bytes in 0 blocks
==2994== Rerun with --leak-check=full to see details of leaked memory
==2994==
==2994== For lists of detected and suppressed errors, rerun with: -s
==2994== ERROR SUMMARY: 153 errors from 10 contexts (suppressed: 0 from 0)
I prepared an auxiliary repository that automatically reproduces the issue with a GitHub pipeline: https://github.com/1ma/php-jit-bug/blob/master/.github/workflows/ci.yml
PHP Version
PHP 8.4.15 (cli) (built: Dec 9 2025 12:39:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.15, Copyright (c) Zend Technologies
with Zend OPcache v8.4.15, Copyright (c), by Zend Technologies
PHP 8.5.0 (cli) (built: Dec 9 2025 12:40:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.0, Copyright (c) Zend Technologies
with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies
Operating System
Ubuntu 24.04
Reactions are currently unavailable