summaryrefslogtreecommitdiff
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2019-10-09 12:37:30 -0500
committerGitHub <noreply@github.com>2019-10-09 12:37:30 -0500
commitecbf35f9335b0420cb8adfda6f299d6747a16515 (patch)
tree3f011932f3e968a91391a6931346825596525f60 /Modules/gcmodule.c
parent01171ebd966b0cd6352057799ad876dd1e07942e (diff)
downloadcpython-git-ecbf35f9335b0420cb8adfda6f299d6747a16515.tar.gz
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.
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 2b47abae1a..766f8e0c67 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -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);
}