public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: jkratoch@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-tromey-python: Fix double-free crash in gdbpy_search_memory.
Date: Tue, 24 Feb 2009 01:07:00 -0000	[thread overview]
Message-ID: <20090224010701.12629.qmail@sourceware.org> (raw)

The branch, archer-tromey-python has been updated
       via  20340ed988af98c24acd5efac0f36b015d3caf6a (commit)
      from  02bcb2e138d6dc35eebb59cebd43803325cc01fb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 20340ed988af98c24acd5efac0f36b015d3caf6a
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Tue Feb 24 01:55:26 2009 +0100

    Fix double-free crash in gdbpy_search_memory.
    
    Any cleanups get automatically executed on an exception.  Therefore the current
    code was executing the cleanup handlers twice causing a crash.  Unreproducible
    on archer-tromey-python but it was segfaulting gdb.python/find.exp in a merged
    tree.
    
    	* python/python.c (gdbpy_search_memory): Move `cleanups' and its
    	execution inside TRY_CATCH.  New comment on `cleanups'.

-----------------------------------------------------------------------

Summary of changes:
 gdb/python/python.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

First 500 lines of diff:
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 5836a15..9a2c00c 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -488,7 +488,6 @@ gdbpy_search_memory (PyObject *self, PyObject *args)
   char *pattern_buf;
   ULONGEST pattern_len, search_space_len;
   PyObject *pattern, *list = NULL, *start_addr_obj;
-  struct cleanup *cleanups = NULL;
   volatile struct gdb_exception except;
 
   /* Assume CORE_ADDR corresponds to unsigned long.  */
@@ -534,7 +533,9 @@ gdbpy_search_memory (PyObject *self, PyObject *args)
 	{
 	  if (get_search_pattern (pattern, size, &pattern_buf, &pattern_len))
 	    {
-	      cleanups = make_cleanup (xfree, pattern_buf);
+	      /* Any cleanups get automatically executed on an exception.  */
+	      struct cleanup *cleanups = make_cleanup (xfree, pattern_buf);
+
 	      list = PyList_New (0);
 
 	      while (search_space_len >= pattern_len && found_count < max_count)
@@ -550,14 +551,13 @@ gdbpy_search_memory (PyObject *self, PyObject *args)
 		  PyList_Append (list, PyLong_FromUnsignedLong (found_addr));
 		  ++found_count;
 		}
+
+	      do_cleanups (cleanups);
 	    }
 	}
     }
   GDB_PY_HANDLE_EXCEPTION (except);
 
-  if (cleanups)
-    do_cleanups (cleanups);
-
   return list;
 }
 


hooks/post-receive
--
Repository for Project Archer.


                 reply	other threads:[~2009-02-24  1:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090224010701.12629.qmail@sourceware.org \
    --to=jkratoch@sourceware.org \
    --cc=archer-commits@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).