Skip to content

Fix Context cycle collection and GC ownership - #312

Merged
EdmondDantes merged 1 commit into
mainfrom
fix/context-cycle-gc
Oct 7, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
fix/context-cycle-gc

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

Contexts that retain themselves as a value or object key cannot be collected because Context does not expose its internal references to Zend GC. Coroutine and Scope also expose the context's contents instead of their owned reference to the Context object.

Add Context's GC handler, enumerate the actual Context ownership edges from Coroutine and Scope, and release the context tables in free_obj so they remain valid during GC's traversal after destructors.

The regression test checks automatic collection of standalone value/key cycles and collection of contexts owned by completed coroutines and disposed scopes.

Validation: 94 Context/Scope/GC PHPT passed with four workers on PHP 8.6.0-dev, ZTS debug, TrueAsync ABI 0.26.0. git diff --check passed.

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@EdmondDantes
EdmondDantes merged commit c95dcf7 into main Oct 7, 2026
9 checks passed
@EdmondDantes
EdmondDantes deleted the fix/context-cycle-gc branch October 7, 2026 16:50
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.

1 participant