diff options
author | Tim Peters <tim.peters@gmail.com> | 2019-10-21 16:21:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 16:21:35 (GMT) |
commit | 1e73945470644202262e1ddee2b49e2708a29794 (patch) | |
tree | 5941be7bebb0c1349edfc95eac656eafa2dcf3ac /Modules | |
parent | 5bc6a7c06eda20ba131ecba6752be0506d310181 (diff) | |
download | cpython-1e73945470644202262e1ddee2b49e2708a29794.zip cpython-1e73945470644202262e1ddee2b49e2708a29794.tar.gz cpython-1e73945470644202262e1ddee2b49e2708a29794.tar.bz2 |
visit_reachable: replace release-mode test with an assert. (GH-16866)
It should be impossible for an untracked object to have the collecting
flag set. Back when state was stored in gc_refs, it obviously was
impossible (gc_refs couldn't possibly have a positive & negative value
simultaneously). While the _implementation_ of "state" has gotten much
more complicated, it's still _logically_ just as impossible.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/gcmodule.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 9750d2a..1307aa3 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -468,13 +468,16 @@ visit_reachable(PyObject *op, PyGC_Head *reachable) PyGC_Head *gc = AS_GC(op); const Py_ssize_t gc_refs = gc_get_refs(gc); - // Ignore untracked objects and objects in other generation. + // Ignore objects in other generation. // This also skips objects "to the left" of the current position in // move_unreachable's scan of the 'young' list - they've already been // traversed, and no longer have the PREV_MASK_COLLECTING flag. - if (gc->_gc_next == 0 || !gc_is_collecting(gc)) { + if (! gc_is_collecting(gc)) { return 0; } + // It would be a logic error elsewhere if the collecting flag were set on + // an untracked object. + assert(gc->_gc_next != 0); if (gc->_gc_next & NEXT_MASK_UNREACHABLE) { /* This had gc_refs = 0 when move_unreachable got |