[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-20 Thread Ziyue Jiang
Ziyue Jiang added the comment: Thanks for replying. I did fix my code by adding Py_TPFLAGS_DEFAULT. It's okay. I just think the behavior is a little strange when I don't set the default flag, thus adding this issue. -- ___ Python tracker

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-20 Thread Petr Viktorin
Change by Petr Viktorin : -- keywords: +patch pull_requests: +25808 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27260 ___ Python tracker ___

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-20 Thread Petr Viktorin
Petr Viktorin added the comment: Please use Py_TPFLAGS_DEFAULT when creating objects. Do you have a reason to not do it? The flag Py_TPFLAGS_HAVE_VERSION_TAG is unneeded and Python should not check for it. There's bpo-42747 open for that already; I sent a PR for it. -- nosy:

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-09 Thread Ziyue Jiang
Ziyue Jiang added the comment: I just take over a Python3.6 project from a friend, migrating it to the newest Python version. Then this problem happened. After debugging, I think it's a possible double Py_XDECREF if using C-API like this. But I'm not familiar with Python C-API before so I'm

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-09 Thread Ziyue Jiang
Ziyue Jiang added the comment: Sorry, not inherited from Time, Time is the class I use in a real project. Time -> A -- ___ Python tracker ___

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-09 Thread Ziyue Jiang
Ziyue Jiang added the comment: I have no detailed code. The way to I produce it is that using PyType_FromSpec() to generate a type A without the flag Py_TPFLAGS_DEFAULT(which sets the flag Py_TPFLAGS_HAVE_VERSION_TAG). Then compile and run in Python. from my_pkg import A class Time1(Time):

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-09 Thread Irit Katriel
Irit Katriel added the comment: Do you have a small piece of code reproducing it that you can upload? -- nosy: +iritkatriel ___ Python tracker ___

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-09 Thread Ziyue Jiang
Ziyue Jiang added the comment: Maybe a little complicared but you can still construct a case to trigger the double free action, thus causing a SIGABRT. Program received signal SIGABRT, Aborted. 0x77c3718b in raise () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0

[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-09 Thread Ziyue Jiang
New submission from Ziyue Jiang : The type_mro_modified() function in Object/typeobject.c may produce double Py_XDECREF on mro_meth and type_mro_meth when enter the code: if (!_PyType_HasFeature(cls, Py_TPFLAGS_HAVE_VERSION_TAG) || !PyType_IsSubtype(type, cls)) { goto clear; } I think