Ref counting based object release is not applied if cycle is broken in destructor during GC run
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
repro: https://3v4l.org/USrWu
see UPDATE below
It seems the GC can be improved. Currently, when a cycle is broken during GC run, a 2nd run of GC is needed to really release the object.
https://github.com/php/php-src/commit/b58d74547f "solves this issue" since PHP 8.2+, but is that the most efficient solution for everything? If a cycle (all cycles/references to an object) is explicitly broken during GC, is there anything againts releasing that object by standard refcounting?
Resulted in this output:
d
gc
bool(true) <- notice object is kept alive after the destructor has broken the cycle (and refcount dropped to 0)
gc rerun
bool(false)
bool(false)
done
But I expected this output instead:
d
gc
bool(false)
gc rerun
bool(false)
bool(false)
done
UPDATE:
Based on https://3v4l.org/mgoqd I would call this a bug as 2nd WeakReference::get() call is expected to always give the same result if no GC is run in between the calls.
PHP Version
any (tested PHP 7.4, 8.3)
Operating System
any
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 der Ausführung der Reproduktion unter https://3v4l.org/USrWu und vergleiche sie mit dem aktualisierten Beispiel unter https://3v4l.org/mgoqd. Konzentriere dich dabei auf GC, Destruktoren, Referenzzähler und WeakReference::get(). Die Aufgabe ist abgeschlossen, wenn ein während eines GC-Laufs durchbrochener Zyklus das Objekt sofort freigibt, sodass beide WeakReference-Prüfungen ohne einen zweiten GC-Lauf mit der erwarteten Ausgabe übereinstimmen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100