public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python: Fix double-free crash in gdbpy_search_memory.
@ 2009-02-24  1:07 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2009-02-24  1:07 UTC (permalink / raw)
  To: archer-commits

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-24  1:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24  1:07 [SCM] archer-tromey-python: Fix double-free crash in gdbpy_search_memory jkratoch

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).