Delaying destructors and GC
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
Due to destructors and the cycle collector, zval_ptr_dtor() may have more effects than just freeing the given zval. This is the cause of bugs and workarounds.
These bugs and workarounds could be avoided by delaying destructors and GC runs until a safepoint is reached. If we use vm interrupts as safepoints, this would delay destructors until the next branch/loop or function call (this should be defined more precisely), which seems reasonable.
I'm creating this ticket to aggregate issues that would not exist with delayed destructors and GC runs:
- 3d2b1753393b
- 6f38acfaf906
- https://bugs.php.net/bug.php?id=71020
- https://bugs.php.net/bug.php?id=73423
- https://github.com/php/php-src/issues/10168
- https://github.com/php/php-src/issues/13612
- https://github.com/php/php-src/issues/16464
- https://github.com/php/php-src/issues/16478
- https://github.com/php/php-src/issues/16479
- https://github.com/php/php-src/issues/16646
- https://github.com/php/php-src/issues/17162
- https://github.com/php/php-src/issues/18209
- https://github.com/php/php-src/issues/19999
- https://github.com/php/php-src/issues/20405
- https://github.com/php/php-src/issues/20477
- https://github.com/php/php-src/issues/20657
- https://github.com/php/php-src/issues/21824
- https://github.com/php/php-src/issues/22061
- https://github.com/php/php-src/issues/22062
https://github.com/php/php-src/pull/19787 delays GC runs, but not destructors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with zval_ptr_dtor() and the VM-interrupt/safepoint discussion, then compare pull request 19787, which delays GC runs but not destructors. Done would require a defined safepoint policy and a complete implementation addressing the aggregated cases listed in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100