Repository navigation
merge: cascade 8.4 into 8.5 (hot-swap cache fix, header refresh) - #305
Merged
Merged
Conversation
…eload next to opcache.preload Under PHP's default ffi.enable=preload a web SAPI may call the FFI API only from code that opcache.preload compiled at server start, so a bridge that was not preloaded cannot bind the engine at all - not even through FFI::scope() over definitions that ffi.preload published. Core::init() answered that with "Preload mode requires that you call Core::preload before", which names a method the operator has no place to call from. The exception is now the php.ini recipe with the paths resolved for the very build that failed: opcache.preload pointed at the bundled preload.php (any script that requires the autoloader does), opcache.preload_user for an FPM master running as root, what ffi.preload does and does not do, the Windows case where opcache.preload does not exist, and a diagnosis of the settings already in place. Core::preloadConfigurationHint() returns the same text on demand; Core::engineHeaderPath() resolves the ffi.preload value for the running build and Core::preloadScriptPath() the opcache.preload one. Configuring ffi.preload together with opcache.preload crashed the server start with a segmentation fault: the preload stage loaded the header into a scope that module startup had already published. Core::preload() now takes an existing scope as is and loads the header only when there is none. Tests run php-cgi (SAPI cgi-fcgi, restricted like php-fpm) next to the CLI binary: the exception carries the recipe, the recipe boots a request, both preloading mechanisms can be combined (the crash reproduces without the guard), and ffi.preload serves a request under ffi.enable=1. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VLQcsvgdQUzwBFsoKUAcG2
feat(core): explain the preload-mode configuration and survive ffi.preload next to opcache.preload
… swap
HotSwap compiles the new source as a donor class under the same name. When the
donor has a parent or interfaces, zend_do_link_class() stores it in the
engine's per-name class-entry cache. HotSwap republished the live entry in the
class table but left that cache pointing at the donor, so any later lookup by
an interned name (new ReflectionClass('Foo'), new Foo, ...) returned the donor
after it was destroyed on apply() or discard(): a use-after-free.
A PHP debug build catches it as a hash-table consistency abort in
ClassDeltaTest::testRemovedOverrideRestoresInheritedMethod; release builds
read freed memory silently.
ReflectionClass::bindClassNameCache() now repoints the slot, and HotSwap calls
it right after republishing the live class. The new regression test compares
class-entry addresses, so it fails on release builds too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
PHP 8.4.27 added two engine fields: - zend_compiler_globals.interned_strings_fallible (_Bool, in the former padding at offset 443, so ast stays at 448) - zend_executor_globals.delayed_oom (new zend_oom_info struct, appended at the end; EG grows 1960 -> 1984 bytes, 2128 -> 2152 on ZTS) No existing offset moves. Regenerated with `composer gen-headers` (docker, php:8.4); the darwin and windows targets follow from their workflows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
chore(gen): regenerate 8.4 engine definitions for PHP 8.4.27
…govq fix(core): repoint the class-name cache at the live class after a hot swap
Brings the hot-swap class-name cache fix (#302) and the PHP 8.4.27 header refresh (#303) into 8.5. README conflict: kept the 8.5 side, which carries the Windows paragraph that the #299 cascade resolution added on purpose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
PHP 8.5.12 carries the same engine additions as 8.4.27: - zend_compiler_globals.interned_strings_fallible (_Bool, former padding at offset 443) - zend_executor_globals.delayed_oom (zend_oom_info, appended at the end; EG grows 1984 -> 2008 bytes, 2152 -> 2176 on ZTS) No existing offset moves. Regenerated with `composer gen-headers` (docker, php:8.5). The branch-level stubs and .phpstorm.meta.php regenerate identical to what the cascade merge produced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
The darwin generator now finds a ZTS PHP 8.5 build on the Intel macOS runner and committed include/8.5/darwin-x64-zts, which the README footnote said would happen automatically. The CI leg that skipped while the target was missing now runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
setup-php now provides that build, and include/8.5/darwin-x64-zts is committed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Resolves the conflicted automated cascade #304 (
8.4→8.5). It brings in #302 (the hot-swap class-name cache use-after-free fix) and #303 (the PHP 8.4.27 header refresh).f713dcb): the only textual conflict was inREADME.md. I kept the 8.5 side, which carries the Windowsopcache.preloadparagraph that the merge: cascade 8.4 into 8.5 (preload-mode configuration) #299 resolution added on purpose. The branch-levelstubs/zend-engine-structs.phpand.phpstorm.meta.phpmerged cleanly. As AGENTS.md asks, I regenerated them on this branch from the canonical 8.5 build, and the output is byte-identical to the merged text.d52706c,4560965,b2a1dfa): PHP 8.5.12 carries the same engine additions as 8.4.27. That iszend_compiler_globals.interned_strings_fallibleat offset 443 (former padding), andzend_executor_globals.delayed_oom(zend_oom_info) appended to EG, which grows 1984 → 2008 bytes (2152 → 2176 on ZTS). No existing offset moves. I regenerated linux withcomposer gen-headers(Docker,php:8.5), and darwin/windows came from their generator workflows run on this branch. Without this, the 8.5 header-drift checks fail the same way the 8.4 ones did.include/8.5/darwin-x64-zts: the darwin generator now finds a ZTS PHP 8.5 build on the Intel macOS runner. This is the case the README footnote said would land automatically. TheTests (macOS x64, zts)leg, which skipped while the target was missing, now runs. I updated the README support table and the matching AGENTS.md note (8b5dc69,ee1399e).Once this merges,
8.5contains the8.4tip, so GitHub should close #304 as merged on its own.Environment it was verified on
PHP 8.5.12 (cli) (NTS), officialphp:8.5-cliDocker image plus ext-ffi--enable-debug)? nocomposer teston the merged tree: 604 tests, no failures or errors (5 skipped, 5 incomplete), including the newClassDeltaTest::testNameLookupResolvesLiveClassAfterSwapOfLinkedClass.Checklist
8.4→8.5)composer testpasses on the matching PHP minor (8.5.12)composer phpstan(level max) andcomposer cs:checkare green (left to CI)include/,stubs/or.phpstorm.meta.phpwas hand-edited; regenerated on the target branchGenerated by Claude Code