[Python-checkins] python/dist/src/Objects object.c,2.162.6.4,2.162.6.5

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 08 Jul 2002 15:30:55 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv18101/Objects

Modified Files:
      Tag: release22-maint
	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.

Note:  test_gc fails in a COUNT_ALLOCS build now, because it expects
a new-style class to get garbage collected.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.162.6.4
retrieving revision 2.162.6.5
diff -C2 -d -r2.162.6.4 -r2.162.6.5
*** object.c	13 Jun 2002 21:39:47 -0000	2.162.6.4
--- object.c	8 Jul 2002 22:30:52 -0000	2.162.6.5
***************
*** 80,83 ****
--- 80,92 ----
  			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;
  	}