-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Possible double Py_XDECREF in cpython typeobject.c #88754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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: I think |
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. |
Do you have a small piece of code reproducing it that you can upload? |
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):
def __init__(self):
pass
import multiprocessing (This import is a method to 100% reproduce it. Another way is to use python3-dbg running the code.) |
Sorry, not inherited from Time, Time is the class I use in a real project. |
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. |
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. |
Thanks for replying. |
You should set |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: