Skip to content

merge: cascade 8.4 into 8.5 (hot-swap cache fix, header refresh) - #305

Merged
lisachenko merged 15 commits into
8.5from
merge/cascade-8.4-into-8.5-hotswap-cache
Nov 7, 2026
Merged

lisachenko merged 15 commits into
8.5from
merge/cascade-8.4-into-8.5-hotswap-cache

Conversation

@lisachenko

Copy link
Copy Markdown
Owner

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).

  • Merge (f713dcb): the only textual conflict was in README.md. I kept the 8.5 side, which carries the Windows opcache.preload paragraph that the merge: cascade 8.4 into 8.5 (preload-mode configuration) #299 resolution added on purpose. The branch-level stubs/zend-engine-structs.php and .phpstorm.meta.php merged 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.
  • 8.5 header refresh (d52706c, 4560965, b2a1dfa): PHP 8.5.12 carries the same engine additions as 8.4.27. That is zend_compiler_globals.interned_strings_fallible at offset 443 (former padding), and zend_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 with composer 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.
  • New target 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. The Tests (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.5 contains the 8.4 tip, so GitHub should close #304 as merged on its own.

Environment it was verified on

  • PHP version: PHP 8.5.12 (cli) (NTS), official php:8.5-cli Docker image plus ext-ffi
  • Thread safety: NTS (ZTS left to CI)
  • OS / architecture: Linux x64
  • Debug build (--enable-debug)? no

composer test on the merged tree: 604 tests, no failures or errors (5 skipped, 5 incomplete), including the new ClassDeltaTest::testNameLookupResolvesLiveClassAfterSwapOfLinkedClass.

Checklist

  • Targets the minimum affected version branch (cascade 8.4 → 8.5)
  • composer test passes on the matching PHP minor (8.5.12)
  • composer phpstan (level max) and composer cs:check are green (left to CI)
  • Tests added or updated: carried in from fix(core): repoint the class-name cache at the live class after a hot swap #302
  • Nothing under include/, stubs/ or .phpstorm.meta.php was hand-edited; regenerated on the target branch
  • Conventional Commits used for the commit messages

Generated by Claude Code

lisachenko and others added 15 commits October 10, 2026 20:18
…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
@lisachenko
lisachenko marked this pull request as ready for review November 7, 2026 10:05
@lisachenko
lisachenko merged commit 81e3530 into 8.5 Nov 7, 2026
21 checks passed
@lisachenko
lisachenko deleted the merge/cascade-8.4-into-8.5-hotswap-cache branch November 7, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants