mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-38379: don't claim objects are collected when they aren't (#16658)
* bpo-38379: when a finalizer resurrects an object, nothing is actually collected in this run of gc. Change the stats to relect that truth.
This commit is contained in:
parent
01171ebd96
commit
ecbf35f933
3 changed files with 75 additions and 6 deletions
|
@ -1095,12 +1095,9 @@ collect(struct _gc_runtime_state *state, int generation,
|
|||
validate_list(&finalizers, 0);
|
||||
validate_list(&unreachable, PREV_MASK_COLLECTING);
|
||||
|
||||
/* Collect statistics on collectable objects found and print
|
||||
* debugging information.
|
||||
*/
|
||||
for (gc = GC_NEXT(&unreachable); gc != &unreachable; gc = GC_NEXT(gc)) {
|
||||
m++;
|
||||
if (state->debug & DEBUG_COLLECTABLE) {
|
||||
/* Print debugging information. */
|
||||
if (state->debug & DEBUG_COLLECTABLE) {
|
||||
for (gc = GC_NEXT(&unreachable); gc != &unreachable; gc = GC_NEXT(gc)) {
|
||||
debug_cycle("collectable", FROM_GC(gc));
|
||||
}
|
||||
}
|
||||
|
@ -1122,6 +1119,7 @@ collect(struct _gc_runtime_state *state, int generation,
|
|||
* the reference cycles to be broken. It may also cause some objects
|
||||
* in finalizers to be freed.
|
||||
*/
|
||||
m += gc_list_size(&unreachable);
|
||||
delete_garbage(state, &unreachable, old);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue