feat(memory): merge the 8.4 allocator seam up to master (#223) - #226
Merged
Conversation
Brings the allocator seam, ObjectEntry store registration and the external arData install API from the 8.4 line up to master (PHP 8.5), per the branch flow in AGENTS.md. Master's 8.5-specific engine handling is preserved as-is; the seam touches no generated artifacts under include/, stubs/ or .phpstorm.meta.php. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B9xaBchjdo1atarNZ6sZqe
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
Cascade merge of branch
8.4intomasterper the branch flow inAGENTS.md(
.github/branch-flow.json:8.4 -> master). It carries the allocator seam workof #223 — merged into
8.4as #224 — up to the PHP 8.5 line.What arrives on
master:ZEngine\Memory\Allocator— the allocation seam interface, withZEngine\Memory\EngineAllocator(the three modes the persistent primitives usedto hardcode: tracked-persistent, tracked-request, untracked-persistent) and
ZEngine\Memory\AllocationException.PersistentHashTable,PersistentObjectFactory,PersistentGraphCloner,StringEntry,HashTable.arDatainstall API onHashTable/PersistentHashTable, plusPersistentHashTable::addInterned()for caller-owned key strings.ObjectEntry(
register()/unregister()), andReflectionClass::fromClassTable()— aclass-table probe that does not autoload.
Core::offsetOfField(), the named form oftype(...)->getStructFieldOffset(...)so no rawFFI\CTypecrosses the APIboundary.
tests/Memory/AllocatorSeamTest.php,tests/Memory/EngineAllocatorTest.php,tests/Type/ObjectEntryRegistrationTest.php,tests/Type/PersistentHashTableExternalStorageTest.php,tests/Stub/RecordingArenaAllocator.php.This unblocks the red PHP 8.5 CI legs on
lisachenko/php-shared-data-extension#21, which needs the seam on the 8.5 line.
Refs #223, merges #224.
Conflict resolution
The merge applied without textual conflicts. Master's 8.5-specific work and the
8.4 seam work turned out to be almost disjoint, so the only two files needing a
three-way merge were resolved by git and verified by hand:
src/Core.php— master's 8.5 constants and boot guard are untouched(
SUPPORTED_PHP_VERSION_ID = [80500, 80600],ZEND_ACC_USE_GUARDS = 0x40000000"was 0x800 before PHP 8.5", the "for PHP 8.5" doc header); the seam contributes
only the new
offsetOfField()method, appended afterfree().tests/Reflection/ReflectionClassTest.php— master's 8.5 adaptation survives(
@ini_set('report_memleaks', …), deprecated on 8.5); the seam appends the twofromClassTable()tests.The remaining seam files (
src/Memory/*,src/Type/{HashTable,PersistentHashTable, PersistentObjectFactory,StringEntry,ObjectEntry,TypeOperationException}.php,src/Memory/PersistentGraphCloner.php,src/Reflection/ReflectionClass.php,docs/persistent-heap.md, the new tests) had no counterpart change onmasterandcame across as fast-forwards/additions.
src/System/ObjectStore.phpwas not touchedby the seam PR at all.
Nothing under
include/,stubs/or.phpstorm.meta.phpis in this merge — theseam PR touched no generated artifacts, so no conflict arose there and no
regeneration is required. The seam code carries no
PHP_VERSION_IDbranches anddereferences no struct whose 8.5 layout differs (it does not touch
op_array, sothe 8.5
literals/refcountdifferences are not in play).8.5 gate evidence
Every run below is
php8.5 -d ffi.enable=1 -d opcache.jit=off. Each suite run wascompared against a baseline run of
origin/masterin the same checkout.origin/masterbaselinecomposer testcomposer test:internal(--group internal --process-isolation)--filter 'EngineAllocator|AllocatorSeam|ExternalStorage|ObjectEntryRegistration')MALLOC_CHECK_=3 MALLOC_PERTURB_=85composer phpstan(level max)composer cs:check(@PER-CS2.0)The merge adds 35 passing tests and no new failures: the pre-existing red tests
on the 8.5 line (
ClassSpecializerSlotTest,ExecutionDataTest,RedefineLeakPlateauTest,PersistentHeapRequestCycleTest,SharedMemoryExceptionTest,FunctionLikeInfoTest,ReflectionClassParentTest,ReflectionClassResolutionHandlersTest,ReflectionFunctionTest::testRedefine)fail identically before and after, and are out of scope for this merge-up.
The
MALLOC_CHECK_/MALLOC_PERTURB_run specifically confirms that theuse-after-free fix from
8.4commit1a6acb6("drop the materialized alias beforefreeing a registered clone") survived the merge intact —
src/Type/ObjectEntry.phpand
tests/Type/ObjectEntryRegistrationTest.phpare byte-identical to their8.4state, and the run that used to abort with
malloc(): unaligned tcache chunk detectedcompletes cleanly. No segfaults oraborts were observed in any run.
Environment it was verified on
php -v):PHP 8.5.9 (cli) (built: Jul 30 2026 15:13:42) (NTS)--enable-debug)? noChecklist
cascade: the work landed on
8.4(feat(memory): allocator seam for persistent cloning + external arData install (closes #223) #224) and is merged intomasterhere,never cherry-picked down
composer testpasses on the matching PHP minor (no new failures vs theorigin/masterbaseline; 35 new seam tests green)composer phpstan(level max) andcomposer cs:checkare greenlayout_structsintools/generator/symbols.phpis unchanged)tools/generator/symbols.phpunchanged — nothing underinclude/,stubs/or
.phpstorm.meta.phpwas touched or hand-edited🤖 Generated with Claude Code
https://claude.ai/code/session_01B9xaBchjdo1atarNZ6sZqe
Generated by Claude Code