[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Thanks!

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Rostislav Kondratenko


Rostislav Kondratenko  added the comment:

Hello, I don't have that code, as I worked around that issue at the time.
I checked with my project, using PyObject_GC_New works fine.
It seems that since then the issue has been fixed at some point since 2017.
Either that or I misinterpreted what was going on back then.
I think we can safely close this issue.

On Tue, 15 Jun 2021 at 14:18, Irit Katriel  wrote:

>
> Irit Katriel  added the comment:
>
> Do you still have the code that created the crash? It would help to
> understand what you are/were seeing.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Do you still have the code that created the crash? It would help to understand 
what you are/were seeing.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2021-06-15 Thread Irit Katriel


Irit Katriel  added the comment:

Are you sure? It seems to me that they both incref the type object in 
_PyObject_Init:
https://github.com/python/cpython/blob/689a84475e7b1da79d5ae82df67ab8897316f98c/Include/internal/pycore_object.h#L43

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32322] Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not incrementing type object refcout in PyObject_GC_New

2017-12-14 Thread Rostislav Kondratenko

New submission from Rostislav Kondratenko :

If one creates a type with both Py_TPFLAGS_HAVE_GC and Py_TPFLAGS_HEAPTYPE set 
and implemented, one has to create instances with PyObject_GC_New() per current 
docs: https://docs.python.org/3.7/c-api/gcsupport.html .

However, PyObject_GC_New() unlike PyType_GenericAlloc() does not increment 
refcount of a type object. As the refcount is still decremented when instances 
are destroyed, it leads to steady drain on type object's refcount. Eventually 
it reaches zero and the type object gets deleted while there are still 
instances and references to it. And it usually results in crash after a number 
of instances (20-50 is usually enough) is created and destroyed.

One should either update the docs to point that call to PyType_GenericAlloc() 
would be sufficient (as it would use _PyObject_GC_Malloc() and increment 
refcount when appropriate) or update _PyObject_GC_New() code to increment type 
object's refcount when the type is heap type. Or both.

--
assignee: docs@python
components: Documentation, Interpreter Core
messages: 308302
nosy: docs@python, rkond
priority: normal
severity: normal
status: open
title: Heap type with Py_TPFLAGS_HAVE_GC leads to segfault due to not 
incrementing type object refcout in PyObject_GC_New
type: crash
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com