[Python-bugs-list] [ python-Bugs-578752 ] COUNT_ALLOCS vs heap types

noreply@sourceforge.net noreply@sourceforge.net
Mon, 08 Jul 2002 15:14:54 -0700


Bugs item #578752, was opened at 2002-07-08 12:29
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=578752&group_id=5470

Category: Type/class unification
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Tim Peters (tim_one)
Summary: COUNT_ALLOCS vs heap types

Initial Comment:
A COUNT_ALLOCS build blows up with a memory fault 
while printing statistics at exit after running the test suite.

Running test_descr alone is enough to provoke this.

This example doesn't blow up, but gets into an infinite 
stats-printing loop at exit:

"""
import gc

for i in range(8):
    class C(object):
        pass
    c = C()
    print gc.collect()
"""

I believe the scoop here is that COUNT_ALLOCS assumes 
type objects are immortal.  When a type object goes away, 
it doesn't get unlinked from object.c's type_list, so that the 
stats printing loop can dereference dead memory, and the 
type_list can even become circular if the same memory 
blob happens to get reused for a new heap type later.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-07-08 18:14

Message:
Logged In: YES 
user_id=31435

Fixed, via the simple expedient of doing increfs to account 
for the links in object.c's type_list.  Note that this 
effectively makes new-style classes immortal in a 
COUNT_ALLOCS build.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-07-08 18:00

Message:
Logged In: YES 
user_id=31435

Assigned to me.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=578752&group_id=5470