Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Ali Lakhia <lakhia@alumni.utexas.net>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Memory leak fixes
Date: Tue, 05 Oct 2010 22:47:00 -0000	[thread overview]
Message-ID: <m37hhws1e5.fsf@fleche.redhat.com> (raw)
In-Reply-To: <AANLkTi=gYU1ix8_8G3Ens28=XmZxwuQ+=pqGqfrmM+-T@mail.gmail.com>	(Ali Lakhia's message of "Fri, 1 Oct 2010 17:16:02 -0700")

>>>>> "Ali" == Ali Lakhia <lakhia@alumni.utexas.net> writes:

Ali> Please see fixes for memory leaks.  My testing for these has been
Ali> limited to just making sure things work for my day-to-day use. Thanks,

In addition to what Joel said, I have a couple notes on the patch itself.q

Ali> diff -ru gdb-7.1/gdb/dwarf2read.c gdb-7.1/gdb/dwarf2read.c
Ali> --- gdb-7.1/gdb/dwarf2read.c	2010-09-14 16:59:40.000000000 -0700
Ali> +++ gdb-7.1/gdb/dwarf2read.c	2010-06-15 14:53:54.000000000 -0700
Ali> @@ -5462,6 +5462,7 @@
Ali>    set_descriptive_type (type, die, cu);
Ali>    do_cleanups (back_to);

Ali> +  xfree (range_types);

This one seems to be fixed in CVS.
There is a cleanup covering range_types.

Actually, I see this cleanup in 7.1 as well.
How did you find this leak?

Maybe the logic around creating the cleanup is wrong.

Ali> diff -ru gdb-7.1/gdb/printcmd.c gdb-7.1/gdb/printcmd.c
Ali> --- gdb-7.1/gdb/printcmd.c	2010-09-14 17:03:28.000000000 -0700
Ali> +++ gdb-7.1/gdb/printcmd.c	2010-06-15 14:53:54.000000000 -0700
Ali> @@ -608,6 +608,7 @@
Ali>      fputs_filtered (">", stream);
 
Ali>    do_cleanups (cleanup_chain);
Ali> +  xfree (filename);
Ali>  }

This one is also covered by a cleanup.

Ali> diff -ru gdb-7.1/gdb/python/py-type.c gdb-7.1/gdb/python/py-type.c
Ali> --- gdb-7.1/gdb/python/py-type.c	2010-09-14 17:03:28.000000000 -0700
Ali> +++ gdb-7.1/gdb/python/py-type.c	2010-06-14 14:04:28.000000000 -0700
Ali> @@ -580,6 +580,7 @@
 
Ali>        type_print (type_object_to_type (self), "", stb, -1);
 
Ali> +      xfree (thetype);
Ali>        thetype = ui_file_xstrdup (stb, &length);
Ali>        do_cleanups (old_chain);

I didn't check this one, but if you want to insert a free before a call
to do_cleanups, usually that means you should create a cleanup at the
point of allocation.

Tom


  parent reply	other threads:[~2010-10-05 22:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-02  0:16 Ali Lakhia
2010-10-02  0:57 ` Joel Brobecker
2010-10-05 22:47 ` Tom Tromey [this message]
2010-10-05 23:47   ` Ali Lakhia
2010-10-06 16:19     ` Tom Tromey

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=m37hhws1e5.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lakhia@alumni.utexas.net \
    /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