Repository navigation
[TASK] Collect garbage cycles only between tests - #900
Merged
Merged
Conversation
The functional tests crashed randomly with a segmentation fault on PHP 8.2. Objects of earlier test instances, e.g. the Extbase ReflectionService, are destroyed by the garbage collector. The destructor of the ReflectionService writes the class schemata to the cache, which calls serialize(). If the garbage collector runs while another serialize() is in progress, the nested serialize() frees memory the outer one still uses. A PHPUnit extension disables the automatic garbage collection and collects the cycles after the set up of each test and after each test. Resolves: #899 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Resolves: #899
The functional tests crashed randomly with a segmentation fault (exit code 139) on PHP 8.2, e.g. in #898 (about every second run, locally and in CI).
Cause (core dump and valgrind with
USE_ZEND_ALLOC=0): during an outerserialize()the garbage collector destroys anExtbase\Reflection\ReflectionServiceof an earlier test instance. Its destructor writes the class schemata to the cache and callsserialize()again; the nested call resizes and frees the reference table of the outer call, which reads it afterwards.Tests/PhpUnit/GarbageCollectionExtension, registered inBuild/phpunit.xml.dist: disables the automatic garbage collection and callsgc_collect_cycles()after the set up of each test and after each test.gc_collect_cycles()also collects with the automatic garbage collection disabled (checked on PHP 8.2, 8.3 and 8.4), the memory usage of the functional tests stays the same (305 MB).Verified with the code of #898 on PHP 8.2: without the extension 3 of 5 runs crashed, with it 4 of 4 runs passed (288 tests).