Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-31095: fix potential crash during GC. #2974
Conversation
Some tp_dealloc methods of GC types didn't call PyObject_GC_UnTrack().
|
LGTM (besides two details). But this touches delicate things, and I think this PR needs a review of yet one core developer. |
| @@ -1073,6 +1073,7 @@ lru_cache_clear_list(lru_list_elem *link) | |||
| static void | |||
| lru_cache_dealloc(lru_cache_object *obj) | |||
| { | |||
| _PyObject_GC_UNTRACK(obj); | |||
This comment has been minimized.
This comment has been minimized.
serhiy-storchaka
Aug 3, 2017
Member
_PyObject_GC_UNTRACK() shouldn't be used in types that can be subclassed because it can't be called repeatedly. Otherwise the subclass's destructor would need to call _PyObject_GC_TRACK() before calling parent's destructor:
static void
lru_cache_subclass_dealloc(lru_cache_subclass_object *obj)
{
_PyObject_GC_UNTRACK(obj);
Py_XDECREF(obj->foo);
Py_XDECREF(obj->bar);
_PyObject_GC_TRACK(obj);
lru_cache_dealloc((lru_cache_object *)obj);
}
This looks too fragile.
| @@ -1073,6 +1073,7 @@ lru_cache_clear_list(lru_list_elem *link) | |||
| static void | |||
| lru_cache_dealloc(lru_cache_object *obj) | |||
| { | |||
| _PyObject_GC_UNTRACK(obj); | |||
| lru_list_elem *list = lru_cache_unlink_list(obj); | |||
This comment has been minimized.
This comment has been minimized.
serhiy-storchaka
Aug 3, 2017
Member
Declaration after code is C99 syntax. The code will need rewriting for backporting to 2.7.
| @@ -520,6 +520,7 @@ typedef struct { | |||
| static void | |||
| ast_dealloc(AST_object *self) | |||
| { | |||
| _PyObject_GC_UNTRACK(self); | |||
This comment has been minimized.
This comment has been minimized.
|
lgtm. This suggests that we need a systematic way to deal with this problem, though. |
|
I suggest to add a comment explaining why an explicit Untrack is required. |
This comment has been minimized.
This comment has been minimized.
bedevere-bot
commented
Aug 22, 2017
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
SSL and elementtree changes LGTM |
This comment has been minimized.
This comment has been minimized.
bedevere-bot
commented
Aug 24, 2017
|
GH-3195 is a backport of this pull request to the 3.6 branch. |
see the following sites for details: * https://bugs.python.org/issue31095 * python/cpython#2974 Fixes #35.
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
This comment has been minimized.
This comment has been minimized.
miss-islington
commented
Sep 13, 2017
|
Thanks @methane for the PR |
This comment has been minimized.
This comment has been minimized.
miss-islington
commented
Sep 13, 2017
|
Sorry, @methane, I could not cleanly backport this to |
This comment has been minimized.
This comment has been minimized.
|
The commit 4cde4bd is the backport to Python 2.7. |
call PyObject_GC_UnTrack() in tp_dealloc() see the following sites for details: * https://bugs.python.org/issue31095 * python/cpython#2974
call PyObject_GC_UnTrack() in tp_dealloc() see the following sites for details: * https://bugs.python.org/issue31095 * python/cpython#2974
call PyObject_GC_UnTrack() in tp_dealloc() see the following sites for details: * https://bugs.python.org/issue31095 * python/cpython#2974
call PyObject_GC_UnTrack() in tp_dealloc()
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
call PyObject_GC_UnTrack() in tp_dealloc()
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
see the following sites for details:
* https://bugs.python.org/issue31095
* python/cpython#2974
methane commentedAug 1, 2017
•
edited by bedevere-bot
Some tp_dealloc methods of GC types didn't call PyObject_GC_UnTrack().
https://bugs.python.org/issue31095