Clarification on refcounting behavior of object handlers/get_gc
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
Description
When implementing https://github.com/mongodb/mongo-php-driver/pull/1850, I have encountered some strange refcounting behavior within the garbage collector; specifically, when working with the hashtable returned by get_gc in https://github.com/php/php-src/blob/master/Zend/zend_gc.c#L892 and https://github.com/php/php-src/blob/master/Zend/zend_gc.c#L1516 the refcount is incremented and then seemingly not decremented again (leading to the leaks I'm fighting in https://github.com/mongodb/mongo-php-driver/pull/1850), but in https://github.com/php/php-src/blob/master/Zend/zend_gc.c#L1068, the refcount is decremented correctly.
This brings the question: what should be the refcount of the hashtables returned by get_gc, get_properties_for (in all of the various modes), get_properties, get_debug_info, and all other object handlers?
This detail is not documented anywhere, and specifically for get_gc, it's especially not clear given that returning a refcount of 0 would cause a negative refcount in one place, and returning 1 causes a leak in other two places (though that may be due to an issue in my implementation in the https://github.com/mongodb/mongo-php-driver/pull/1850 PR, though it's not immediately obvious what it is to me).
It would be super nice to have it documented at least inside of the source code as comments too...
PHP Version
8.4.10
Operating System
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den referenzierten Abschnitten von Zend/zend_gc.c um die Zeilen 892, 1068 und 1516 und vergleiche anschließend das Verhalten von get_gc mit get_properties_for, get_properties und get_debug_info. Prüfe den verlinkten mongo-php-driver pull request auf die gemeldeten Leaks; abgeschlossen ist die Aufgabe, wenn die erwartete Refcount-Verantwortlichkeit für jeden Handler festgelegt und in den relevanten Quellcode-Kommentaren dokumentiert ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, php
- Bereich
- documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100