[Python-checkins] python/dist/src/Objects object.c,2.183,2.184
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Mon, 08 Jul 2002 15:12:03 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv12066/python/Objects
Modified Files:
object.c
Log Message:
SF bug 578752: COUNT_ALLOCS vs heap types
Repair segfaults and infinite loops in COUNT_ALLOCS builds in the
presence of new-style (heap-allocated) classes/types.
Bugfix candidate. I'll backport this to 2.2. It's irrelevant in 2.1.
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.183
retrieving revision 2.184
diff -C2 -d -r2.183 -r2.184
*** object.c 7 Jul 2002 19:59:50 -0000 2.183
--- object.c 8 Jul 2002 22:11:52 -0000 2.184
***************
*** 75,78 ****
--- 75,87 ----
Py_FatalError("XXX inc_count sanity check");
tp->tp_next = type_list;
+ /* Note that as of Python 2.2, heap-allocated type objects
+ * can go away, but this code requires that they stay alive
+ * until program exit. That's why we're careful with
+ * refcounts here. type_list gets a new reference to tp,
+ * while ownership of the reference type_list used to hold
+ * (if any) was transferred to tp->tp_next in the line above.
+ * tp is thus effectively immortal after this.
+ */
+ Py_INCREF(tp);
type_list = tp;
}