Skip to content

Fix GH-25220: Clear leftover func_info after JIT setup failure - #25224

Open
rafamolina1 wants to merge 1 commit into
php:PHP-8.4from
rafamolina1:fix-gh25220-jit-func-info
Open

rafamolina1 wants to merge 1 commit into
php:PHP-8.4from
rafamolina1:fix-gh25220-jit-func-info

Conversation

@rafamolina1

Copy link
Copy Markdown

Summary

  • zend_jit_script() builds the call graph in CG(arena) and stores those func_info pointers on every op_array. For delayed JIT triggers (hot counters, first-exec, etc.) it then allocates jit_extension from shared memory, which zend_accel_script_persist_calc() does not reserve.
  • If that allocation fails part-way through the op_arrays, jit_failure released the arena without clearing the remaining FUNC_INFO slots. A later hot compile of a successfully-setup function then reads a callee's stale func_info and segfaults in type inference or zend_jit_cleanup_func_info().
  • Clear FUNC_INFO from the failed index onward on the non-SCRIPT_LOAD failure path so leftover op_arrays no longer point into the freed arena.

Fixes GH-25220

Test plan

  • Compact reproducer (opcache.jit=1235, 8M SHM, 150 classes of 50 methods) segfaults on unpatched PHP 8.5.4 (rc=139)
  • Same reproducer completes on patched PHP 8.4.27
  • make test TESTS=ext/opcache/tests/jit/gh25220.phpt PASSes on the patched build

When hot-counter JIT setup runs out of shared memory mid-script, the
remaining op_arrays kept pointers into the released call-graph arena.
Clear those FUNC_INFO slots on the delayed-trigger jit_failure path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant