Skip to content

Commit eb807ad

Browse files
author
Paulo Henrique Silva
committed
bpo-40071: Fix potential crash in _functoolsmodule.c
Changes on 7dd549e made _functools compatible with PEP-489 and we could have multiple modules instances loaded. But, right now there is no way to make `kwd_mark` global into a per module instance variable. kwd_mark is used on lru_cache_new which does not have a reference to a PyModule*, necessary to use PyModule_GetState. PEP-573 will solve this problem and will allow us to move the global state to per-module data and properly clear the state when unloading a module instance. This change temporarily disable cleaning of kwd_mark to avoid NULL pointer dereference if we clear kwd_mark and other module instances still alive use it. wip
1 parent 00002e6 commit eb807ad

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/_functoolsmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,10 @@ static PyMethodDef _functools_methods[] = {
14131413
static void
14141414
_functools_free(void *m)
14151415
{
1416-
Py_CLEAR(kwd_mark);
1416+
// FIXME: Do not clear kwd_mark to avoid NULL pointer dereferencing if we have
1417+
// other modules instances that could use it. Will fix when PEP-573 land
1418+
// and we could move kwd_mark to a per-module state.
1419+
// Py_CLEAR(kwd_mark);
14171420
}
14181421

14191422
static int

0 commit comments

Comments
 (0)