-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-33930: Fix segfault with deep recursion when cleaning method objects #27678
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
Changes from all commits
a444686
6bcd0a0
80ac4cf
738fecc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix segmentation fault with deep recursion when cleaning method objects. | ||
Patch by Augusto Goulart and Pablo Galindo. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,10 @@ PyCMethod_GetClass(PyObject *op) | |
static void | ||
meth_dealloc(PyCFunctionObject *m) | ||
{ | ||
_PyObject_GC_UNTRACK(m); | ||
// The Py_TRASHCAN mechanism requires that we be able to | ||
// call PyObject_GC_UnTrack twice on an object. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand that, but thanks for the comment! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tim-one added this comment in 803526b but the original change is by @nascheme, committed by @gvanrossum in ff413af with the following description:
The "SF bug" is also available on BPO: https://bugs.python.org/issue535905 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the comment is unclear, maybe we should try to improve it. I believe the main point is that, since the object uses the trashcan, the function version of untrack is used rather than the macro version. The macro is not safe to call twice because it assumes the object is a part of the GC double linked list. At least, that's my memory of it. Why the trashcan calls untrack more than once is obscure and I don't recall why it does so. I would need to study the code. My guess would be because it (ab)uses the GC head pointers to store the object in a special trashcan linked list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be more clear if you would say that the code before |
||
PyObject_GC_UnTrack(m); | ||
ambv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Py_TRASHCAN_BEGIN(m, meth_dealloc); | ||
if (m->m_weakreflist != NULL) { | ||
PyObject_ClearWeakRefs((PyObject*) m); | ||
} | ||
|
@@ -170,6 +173,7 @@ meth_dealloc(PyCFunctionObject *m) | |
Py_XDECREF(m->m_self); | ||
Py_XDECREF(m->m_module); | ||
PyObject_GC_Del(m); | ||
Py_TRASHCAN_END; | ||
} | ||
|
||
static PyObject * | ||
|
Uh oh!
There was an error while loading. Please reload this page.