From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22018 invoked by alias); 15 Sep 2011 18:03:58 -0000 Received: (qmail 22010 invoked by uid 22791); 15 Sep 2011 18:03:57 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,TW_RG,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from qmta09.emeryville.ca.mail.comcast.net (HELO qmta09.emeryville.ca.mail.comcast.net) (76.96.30.96) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Sep 2011 18:03:43 +0000 Received: from omta09.emeryville.ca.mail.comcast.net ([76.96.30.20]) by qmta09.emeryville.ca.mail.comcast.net with comcast id Z6171h0030S2fkCA963dw4; Thu, 15 Sep 2011 18:03:37 +0000 Received: from [10.127.238.91] ([65.206.2.68]) by omta09.emeryville.ca.mail.comcast.net with comcast id Z63W1h00b1U2a2h8V63bFE; Thu, 15 Sep 2011 18:03:39 +0000 From: Paul Koning Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: PING: [Python] Patch to fix memory leak Date: Thu, 15 Sep 2011 18:08:00 -0000 References: <9E006B29-53D6-475E-9024-E1E9933A99C6@comcast.net> To: gdb-patches@sourceware.org Message-Id: Mime-Version: 1.0 (Apple Message framework v1084) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00279.txt.bz2 Ping... I can commit this now but I need approval first. paul Begin forwarded message: > From: Paul Koning > Date: September 6, 2011 2:01:02 PM EDT > To: gdb-patches@sourceware.org > Subject: [Python] Patch to fix memory leak >=20 > PyList_Append increments the reference count of the item being appended t= o the list, and two of the places in the GDB Python code that use it don't = take that into account. The result is a memory leak. The attached patch f= ixes that. >=20 > Tested by using a debug build of Python with reference counting enabled, = and turning on dumping of final leftover objects. >=20 > I don't have commit privs. >=20 > paul >=20 > ChangeLog: >=20 > 2011-09-06 Paul Koning >=20 > * python/py-cmd.c (gdbpy_string_to_argv): Decrement reference > count of item appended to list. > * python/py-type.c (typy_fields): Likewise. >=20 > Index: python/py-cmd.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/python/py-cmd.c,v > retrieving revision 1.15 > diff -u -r1.15 py-cmd.c > --- python/py-cmd.c 5 Aug 2011 14:24:10 -0000 1.15 > +++ python/py-cmd.c 6 Sep 2011 17:50:48 -0000 > @@ -685,14 +685,12 @@ > if (argp =3D=3D NULL > || PyList_Append (py_argv, argp) < 0) > { > - if (argp !=3D NULL) > - { > - Py_DECREF (argp); > - } > + Py_XDECREF (argp); > Py_DECREF (py_argv); > freeargv (c_argv); > return NULL; > } > + Py_DECREF (argp); > } >=20 > freeargv (c_argv); > Index: python/py-type.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/python/py-type.c,v > retrieving revision 1.20 > diff -u -r1.20 py-type.c > --- python/py-type.c 18 Aug 2011 16:17:39 -0000 1.20 > +++ python/py-type.c 6 Sep 2011 17:50:48 -0000 > @@ -246,6 +246,7 @@ > Py_DECREF (result); > return NULL; > } > + Py_DECREF (dict); > } >=20 > return result; >=20