This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Missing INCREF in PyType_Ready
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: ehuss, loewis, mwh
Priority: normal Keywords: patch

Created on 2004-06-26 00:37 by ehuss, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
typeobject.c.patch ehuss, 2004-06-26 00:37 Patch to fix missing INCREF in PyType_Ready
Messages (4)
msg46235 - (view) Author: Eric Huss (ehuss) Date: 2004-06-26 00:37
In PyType_Ready() if the type object you are readying 
does not explicitly define its tp_base value, it will 
default to use PyBaseObject_Type.

However, this assignment does not INCREF the 
PyBaseObject_Type pointer.  Thus, for heap allocated 
type objects, when the type_dealloc() function is 
called, a DECREF is called on tp_base which can 
eventually cause PyBaseObject_Type refcount go to 0, 
at which point bad things happen.
msg46236 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-06-29 16:06
Logged In: YES 
user_id=6656

I'm not sure this is actually a real problem.  I don't think
you can get into the "base == NULL" case with a heap type...
msg46237 - (view) Author: Eric Huss (ehuss) Date: 2004-06-29 18:39
Logged In: YES 
user_id=393416

There are relatively few ways to make a heap allocated type 
object.  I have made a method to create structseq type 
objects on the heap (see sf patch 980098).  There doesn't 
appear to be a direct API to do it, so I did it manually.  Since 
the Type_Ready code has a check for NULL bases, one might 
as well take advantage of it.
msg46238 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-08-18 13:21
Logged In: YES 
user_id=21627

I think the missing INCREF is a bug regardless of whether
the code is dead or not (if it is really dead, the bug is
that is hasn't been removed). I have committed the patch as
typeobject.c 2.263 and 2.241.6.12.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40458
2004-06-26 00:37:09ehusscreate