Skip to content

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

Merged
lisachenko merged 22 commits into
masterfrom
merge/cascade-8.5-into-master-hotswap-cache
Nov 7, 2026
Merged

lisachenko merged 22 commits into
masterfrom
merge/cascade-8.5-into-master-hotswap-cache

Conversation

@lisachenko

@lisachenko lisachenko commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

What this changes

This is the last step of the cascade for #302 (the hot-swap class-name cache use-after-free fix): 8.4 → 8.5 (#305, merged) → master. 8.5 is merged in (587aad9), and the merge added no content change.

Merge c1b6792 (8.5 → master)

  • README.md conflict: I kept master's support table, with the 🚧 8.6 row. I updated the 8.5 row to darwin-x64 (nts, zts) and dropped its footnote, since merge: cascade 8.4 into 8.5 (hot-swap cache fix, header refresh) #305 added include/8.5/darwin-x64-zts.
  • AGENTS.md conflict: I kept master's wording of the skipped-leg note.
  • Also arriving from 8.4/8.5: the hot-swap fix and its regression test, the refreshed include/8.4/* and include/8.5/* definitions, and include/8.5/darwin-x64-zts.

8.6 definitions refresh (82eda89, abe0e22, a758d22)

  • CI's PHP 8.6.0-dev carries the same engine backport as 8.4.27 and 8.5.12. That is zend_compiler_globals.interned_strings_fallible (offset 443, former padding) and zend_executor_globals.delayed_oom (zend_oom_info, appended; EG grows 2200 → 2224 bytes). No existing offset moves.
  • master's committed include/8.6/*, stubs/ and .phpstorm.meta.php predated the backport.
  • I regenerated them with the Generate linux headers and Generate darwin headers workflows. Generate windows headers found nothing to do, because there is no 8.6 Windows target yet.

Workflow fix (2c29a5b)

  • generate-linux-headers.yml now uploads the stubs artifact with include-hidden-files: true.
  • actions/upload-artifact drops dotfiles by default. So the generator never carried .phpstorm.meta.php to its commit job, and that file could not be refreshed: the first regeneration left it stale and header drift stayed red. With the fix, the generator committed it itself (a758d22).

Environment it was verified on

  • PHP version: CI's PHP 8.6.0-dev (61f6bc68) on every leg, plus local PHP 8.6.0RC2 (NTS DEBUG)
  • Thread safety: NTS and ZTS (CI)
  • OS / architecture: Linux x64, macOS x64/arm64, Windows x64 (CI)
  • Debug build (--enable-debug)? yes, locally and in the internal-group legs

CI run #533 on a758d22 passes all checks, including every header-drift leg. Locally on 8.6.0RC2 debug: 606 tests, the opcache gate and 165 internal-group tests all green.

Checklist

  • Targets the minimum affected version branch (cascade 8.5 → master)
  • composer test passes on the matching PHP minor
  • composer phpstan (level max) and composer cs:check are green
  • 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; all of it comes from the generator workflows
  • Conventional Commits used for the commit messages

🤖 Generated with Claude Code

https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR

lisachenko and others added 17 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
Brings the hot-swap class-name cache fix (#302) and the 8.4.27 / 8.5.12
header refreshes into master.

Conflicts:
- README.md: kept master's support table (with the 8.6 row) and updated the
  8.5 row to darwin-x64 (nts, zts); dropped the footnote about the missing
  darwin-x64-zts 8.5 target, which now exists.
- AGENTS.md: kept master's wording of the skipped-leg note.

stubs/zend-engine-structs.php and .phpstorm.meta.php regenerated from the
canonical 8.6 build (PHP 8.6.0RC2) rather than merged textually: 8.6.0RC2
does not have the delayed_oom / interned_strings_fallible backport, so they
stay identical to master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxhC1Ec16gRujMto2EbKdR
…tswap-cache

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

Copy link
Copy Markdown
Owner Author

CI: the Generated * headers up to date checks fail on master's 8.6 definitions

CI installs PHP 8.6.0-dev (61f6bc68, the current PHP-8.6 branch). That build has the same engine backport as 8.4.27 and 8.5.12: zend_compiler_globals.interned_strings_fallible at offset 443, and zend_executor_globals.delayed_oom (zend_oom_info) appended to EG, which grows 2200 → 2224 bytes. No existing offset moves. The committed include/8.6/* predates the backport, so master itself is affected. The fix is not specific to this PR, but it belongs on the cascade.

My local check used 8.6.0RC2, which is older than that backport, so I wrongly kept master's stubs. CI's canonical regeneration produces exactly the stubs the textual merge had.

Fix in progress: I've started Generate linux headers, Generate darwin headers and Generate windows headers via workflow_dispatch on this branch. They commit the refreshed include/8.6/*, stubs/ and .phpstorm.meta.php here. Their GITHUB_TOKEN pushes don't start CI. Once #305 merges, my merge of 8.5 into this branch is a normal push, so CI runs again on the final state.


Generated by Claude Code

github-actions Bot and others added 5 commits November 7, 2026 10:06
actions/upload-artifact skips hidden files unless include-hidden-files is set,
so the linux-stubs artifact never carried .phpstorm.meta.php and the commit
job could not refresh it. After the PHP 8.6 engine gained delayed_oom /
interned_strings_fallible, the generator committed the new stubs but left the
meta file stale, and header-drift kept failing.

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:29
@lisachenko
lisachenko merged commit a440eec into master Nov 7, 2026
25 checks passed
@lisachenko
lisachenko deleted the merge/cascade-8.5-into-master-hotswap-cache branch November 7, 2026 10:29
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