Repository navigation
Bug: GC of a fiber suspended in a file included from a function - #24200
Open
EdmondDantes wants to merge 1 commit into
Open
EdmondDantes wants to merge 1 commit into
EdmondDantes wants to merge 1 commit into
Conversation
A file included, or code eval'd, from a function runs in its own frame over the symbol table of that function. zend_fiber_object_gc() added that table once for each of the two frames, so the collector counted its values twice and decremented their refcounts below zero.
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.
A file included from a function, or code eval'd in it, runs in its own frame over the symbol table of that function.
zend_fiber_object_gc()walks the suspended fiber's frames and adds the symbol table of each one, so a fiber suspended inside such a file added the same table twice: the collector counted its values twice and decremented their refcounts below zero.Reproduction (debug build, no extensions):
Expected:
kept. Actual:zend_gc_delref: Assertion 'p->refcount > 0' failed(debug build).The fix skips a frame whose symbol table is the one the previous frame already added. No behaviour change otherwise.
Test:
Zend/tests/fibers/gc-include-shared-symbol-table.phpt(aborts on PHP-8.4 debug without the fix, passes with it;Zend/tests/fibers97 of 97 pass). The test relies on the debug assertion, so only debug builds detect the bug.