summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-06-20 06:57:32 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-06-20 06:57:32 (GMT)
commit6302ec63fc40dd6ae1ad3003003b6b264422e8e0 (patch)
treebfc0f9146102ef06530d03ed161a8d99f552c352 /Python
parent43afb24c3084305f2e8269ffcb81dc1e233b871c (diff)
downloadcpython-6302ec63fc40dd6ae1ad3003003b6b264422e8e0.zip
cpython-6302ec63fc40dd6ae1ad3003003b6b264422e8e0.tar.gz
cpython-6302ec63fc40dd6ae1ad3003003b6b264422e8e0.tar.bz2
gen_iternext(): repair subtle refcount problem.
NeilS, please check! This came from staring at your genbug.py, but I'm not sure it plugs all possible holes. Without this, I caught a frameobject refcount going negative, and it was also the cause (in debug build) of _Py_ForgetReference's attempt to forget an object with already- NULL _ob_prev and _ob_next pointers -- although I'm still not entirely sure how! Part of the difficulty is that frameobjects are stored on a free list that gets recycled very quickly, so if there's a stray pointer to one of them it never looks like an insane frameobject (never goes trough the free() mangling MS debug forces, etc).
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index cf917db..ea5c537 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -152,6 +152,11 @@ gen_iternext(genobject *gen)
gen->running = 1;
result = eval_frame(f);
gen->running = 0;
+ /* The connection between this frame and its parent is over now, so
+ must NULL out f_back lest it get decref'ed when gen dies (note
+ that eval_frame sets f->f_back without bumping its refcount: we
+ never had a fully legit reference to it). */
+ f->f_back = NULL;
return result;
}