Message328554
The default of PyType_FromSpec for tp_dealloc is wrong!
-------------------------------------------------------
After a long struggle with crashes and leaks, the situation
was finally clarified:
When a type is converted from a static type to a heaptype
via PyType_FromSpec, and the tp_dealloc field is NULL,
then subtype_dealloc is inserted.
This is not correct.
The reasoning in the code is that a heaptype has subtype_dealloc.
But before the conversion, the type was static, and for
static types the function object_dealloc was inserted.
In the given type, the only change is to become a heaptype.
The by default inserted object_dealloc should not be changed,
since the existing code was written with object_dealloc in
mind and not the consequences of replacing it with subtype_dealloc.
Before this solution, I used a dummy function to prevend
subpype_dealloc being inserted, but that caused leaks.
It was hard to understand that the default for a static type
is object_dealloc. After that, it was easy to fix that:
The now correctly working workaround is to explicitly insert
an object_dealloc function whenever the default for tp_dealloc
is NULL.
Again, in order to use this fix, it is necessary to break the
Limited API, because in order to write an object_dealloc function
(it is not public) you need access to type objects. |
|
Date |
User |
Action |
Args |
2018-10-26 14:37:17 | Christian.Tismer | set | recipients:
+ Christian.Tismer, loewis, nascheme, ncoghlan, petr.viktorin, docs@python, serhiy.storchaka, Dormouse759 |
2018-10-26 14:37:17 | Christian.Tismer | set | messageid: <1540564637.28.0.788709270274.issue26979@psf.upfronthosting.co.za> |
2018-10-26 14:37:17 | Christian.Tismer | link | issue26979 messages |
2018-10-26 14:37:17 | Christian.Tismer | create | |
|