This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Dan Rose, brett.cannon, mark.dickinson, methane, miss-islington, serhiy.storchaka, terry.reedy, tim.peters, vstinner
Date 2018-11-27.13:39:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543325961.13.0.788709270274.issue34100@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2018-11-27 13:39:21vstinnersetrecipients: + vstinner, tim.peters, brett.cannon, terry.reedy, mark.dickinson, methane, serhiy.storchaka, miss-islington, Dan Rose
2018-11-27 13:39:21vstinnersetmessageid: <1543325961.13.0.788709270274.issue34100@psf.upfronthosting.co.za>
2018-11-27 13:39:21vstinnerlinkissue34100 messages
2018-11-27 13:39:21vstinnercreate