> New changeset c2e1607a51d7a17f143b5a34e8cff7c6fc58a091 by Miss Islington (bot) (INADA Naoki) in branch 'master'
This change introduced a lot of memory leaks (reference leaks):
https://buildbot.python.org/all/#/builders/1/builds/422
The following change fix "make && ./python -m test -R 3:3 test_code":
diff --git a/Python/compile.c b/Python/compile.c
index acb5cfe29b..cb3e73740d 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1277,6 +1277,7 @@ merge_consts_recursive(struct compiler *c, PyObject *o)
else {
u = k;
}
+ Py_DECREF(k);
Py_INCREF(u);
PyTuple_SET_ITEM(tuple, i, u);
i++;
@@ -1288,6 +1289,7 @@ merge_consts_recursive(struct compiler *c, PyObject *o)
Py_DECREF(key);
return NULL;
}
+ Py_DECREF(PyTuple_GET_ITEM(key, 1));
PyTuple_SET_ITEM(key, 1, new);
}
But I dislike the frozenset branch of merge_consts_recursive(): modifying a tuple is a bad idea. For example, if you replace PyTuple_SET_ITEM() with PyTuple_SetItem(), you get a PyErr_BadInternalCall() because the reference count is greater than 1.
I don't see how to rewrote properly the code, so I reverted (removed) it to let someone else fix the code: PR 10743. |