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.

Author pablogsal
Recipients corona10, lukasz.langa, pablogsal, petr.viktorin, serhiy.storchaka, shihai1991, tim.peters, vstinner
Date 2020-05-22.23:57:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590191846.94.0.41720706871.issue40217@roundup.psfhosted.org>
In-reply-to
Content
Ok, I found the problem. The problem is that the reproduced does not correctly work the reference count of base_class because when construction get tuple of bases:

PyObject *bases = PyTuple_New(1);
result = PyTuple_SetItem(bases, 0, base_class);
if (result) return -1;

PyObject *subclass = PyType_FromModuleAndSpec(m, &subclass_spec, bases);

"PyTuple_SetItem" steals a reference to base_class but "PyModule_AddObject" also does the same, and the refcount is incorrect.

If you add a Py_INCREF before, the crash disappears.
History
Date User Action Args
2020-05-22 23:57:26pablogsalsetrecipients: + pablogsal, tim.peters, vstinner, petr.viktorin, lukasz.langa, serhiy.storchaka, corona10, shihai1991
2020-05-22 23:57:26pablogsalsetmessageid: <1590191846.94.0.41720706871.issue40217@roundup.psfhosted.org>
2020-05-22 23:57:26pablogsallinkissue40217 messages
2020-05-22 23:57:26pablogsalcreate