Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Koning <paulkoning@comcast.net>
To: gdb-patches@sourceware.org
Subject: PING: [Python] Patch to fix memory leak
Date: Thu, 15 Sep 2011 18:08:00 -0000	[thread overview]
Message-ID: <A8222745-9C38-495C-B0A0-5F6B819DA1FC@comcast.net> (raw)
In-Reply-To: <9E006B29-53D6-475E-9024-E1E9933A99C6@comcast.net>

Ping...

I can commit this now but I need approval first.

	paul


Begin forwarded message:

> From: Paul Koning <paulkoning@comcast.net>
> Date: September 6, 2011 2:01:02 PM EDT
> To: gdb-patches@sourceware.org
> Subject: [Python] Patch to fix memory leak
> 
> PyList_Append increments the reference count of the item being appended to 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 fixes that.
> 
> Tested by using a debug build of Python with reference counting enabled, and turning on dumping of final leftover objects.
> 
> I don't have commit privs.
> 
> 	paul
> 
> ChangeLog:
> 
> 2011-09-06  Paul Koning  <pkoning@equallogic.com>
> 
> 	* python/py-cmd.c (gdbpy_string_to_argv): Decrement reference
> 	count of item appended to list.
> 	* python/py-type.c (typy_fields): Likewise.
> 
> Index: python/py-cmd.c
> ===================================================================
> 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 == NULL
> 	      || PyList_Append (py_argv, argp) < 0)
> 	    {
> -	      if (argp != NULL)
> -		{
> -		  Py_DECREF (argp);
> -		}
> +	      Py_XDECREF (argp);
> 	      Py_DECREF (py_argv);
> 	      freeargv (c_argv);
> 	      return NULL;
> 	    }
> +	  Py_DECREF (argp);
> 	}
> 
>       freeargv (c_argv);
> Index: python/py-type.c
> ===================================================================
> 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);
>     }
> 
>   return result;
> 


  parent reply	other threads:[~2011-09-15 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06 19:36 Paul Koning
2011-09-07  9:33 ` Phil Muldoon
2011-09-07 10:35   ` Jan Kratochvil
2011-09-07 12:29   ` Paul Koning
2011-09-08 12:29     ` Sergio Durigan Junior
2011-09-15 18:08 ` Paul Koning [this message]
2011-09-15 18:34   ` PING: " Jan Kratochvil
2011-09-15 20:39     ` Paul Koning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A8222745-9C38-495C-B0A0-5F6B819DA1FC@comcast.net \
    --to=paulkoning@comcast.net \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox