Ref counting based object release is not applied if cycle is broken in destructor during GC run
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la riproduzione su https://3v4l.org/USrWu e confrontala con l’esempio aggiornato su https://3v4l.org/mgoqd, concentrandoti su GC, distruttori, conteggi dei riferimenti e WeakReference::get(). Il lavoro è completato quando un ciclo interrotto durante un’esecuzione di GC rilascia immediatamente l’oggetto, così che entrambi i controlli di WeakReference corrispondano all’output previsto senza una seconda esecuzione di GC.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100