[php-src] PR #24274: Fix preloaded functions JIT-compiled on load being overwritten after restart

From: Date: Mon, 12 Oct 2026 13:37:24 +0000
Subject: [php-src] PR #24274: Fix preloaded functions JIT-compiled on load being overwritten after restart
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-39358@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/24274 Author: pavimus Prepared with an AI assistant (Claude), which also ran the reproduction and the tests on my machine; I reviewed the result. The text below is AI-generated (quoted, as asked in CONTRIBUTING.md). > Found while testing OPcache restarts; reproducible in NTS with a single process. > > zend_jit_startup() records the position > zend_jit_restart() rewinds the JIT buffer to > (dasm_ptr[1]) before preloading runs. With a trigger that > compiles on script load > (opcache.jit=function, i.e. 1205) preloaded functions are > compiled during preloading, after > that point. An OPcache restart then rewinds the buffer below their code while their handlers > still > point into it; the next JIT compilation overwrites it and calling a preloaded function returns > garbage or crashes: > > ``` > GET /call.php -> 1502868 olleh5 > GET /reset.php -> bool(true) > GET /new.php -> (compiles a new script) > GET /call.php -> server dies (SIGSEGV), or garbage like "729977 @U1289143" > ``` > > zend_jit_restart_preloaded_op_array() only restores hot > counters of preloaded functions; for > functions compiled on load there is nothing to restore (the branch for other triggers is under > #if 0 with a TODO). This change records the restart point again > after preloading, so code > generated by preloading survives restarts; traces and functions compiled at runtime are > discarded > as before. > > The test uses the CLI server (preloading + > opcache.jit=function, > opcache_reset(), a new script, > then the preloaded functions again). It fails 3/3 without the fix and passes with it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)

« previous php.git-pulls (#39358) next »