public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python: Testcase for a crash in c_get_string
@ 2009-04-15 11:58 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2009-04-15 11:58 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  2f610b4bdbbca3d0a24e0fafc6e4b4db1deafee6 (commit)
       via  59afbfe2f208af893bfd969667605d641b004462 (commit)
      from  0fd9ef10b36826d1061516095906fff0cd0e5380 (commit)

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

- Log -----------------------------------------------------------------
commit 2f610b4bdbbca3d0a24e0fafc6e4b4db1deafee6
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Apr 15 13:57:09 2009 +0200

    Testcase for a crash in c_get_string
    
    http://sourceware.org/ml/archer/2009-q2/msg00049.html
    
    It reproduces the crash of a failed inferior string read, fixed by:
    	http://sourceware.org/ml/gdb-patches/2009-04/msg00284.html
    
    gdb/testsuite/
    2009-04-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* gdb.python/python-prettyprint.c: Include <string.h>.
    	(struct nullstr): New.
    	(main): New variable `nullstr'.  Clear it.
    	* gdb.python/python-prettyprint.exp (run_lang_tests): Test `nullstr'.
    	* gdb.python/python-prettyprint.py (class pp_nullstr): New.
    	(register_pretty_printers): Register `pp_nullstr'.

commit 59afbfe2f208af893bfd969667605d641b004462
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Apr 15 13:53:30 2009 +0200

    cherry-pick: Fix xfree crash on a failed string read.
    
    gdb/
    	* c-lang.c (c_get_string): Fix xfree crash on a failed string read.
    
    Conflicts:
    
    original commit: 8ecc6922cac67b2bee18e162cfcdc69d5938ffd5

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

Summary of changes:
 gdb/c-lang.c                                    |    2 +-
 gdb/testsuite/gdb.python/python-prettyprint.c   |   10 ++++++++++
 gdb/testsuite/gdb.python/python-prettyprint.exp |    2 ++
 gdb/testsuite/gdb.python/python-prettyprint.py  |   10 ++++++++++
 4 files changed, 23 insertions(+), 1 deletions(-)

First 500 lines of diff:
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 8b5410f..198c088 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -266,7 +266,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
 			 buffer, length);
       if (err)
 	{
-	  xfree (buffer);
+	  xfree (*buffer);
 	  error (_("Error reading string from inferior: %s"),
 		 safe_strerror (err));
 	}
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
index 399be23..0d9110d 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.c
+++ b/gdb/testsuite/gdb.python/python-prettyprint.c
@@ -15,6 +15,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include <string.h>
+
 struct s
 {
   int a;
@@ -143,6 +145,11 @@ void do_nothing(void)
   c = 23;			/* Another MI breakpoint */
 }
 
+struct nullstr
+{
+  char *s;
+};
+
 int
 main ()
 {
@@ -151,10 +158,13 @@ main ()
   string x = make_string ("this is x");
   zzz_type c = make_container ("container");
   const struct string_repr cstring = { { "const string" } };
+  /* Clearing by being `static' could invoke an other GDB C++ bug.  */
+  struct nullstr nullstr;
 
   init_ss(&ss, 1, 2);
   init_ss(ssa+0, 3, 4);
   init_ss(ssa+1, 5, 6);
+  memset (&nullstr, 0, sizeof nullstr);
 
 #ifdef __cplusplus
   S cps;
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.exp b/gdb/testsuite/gdb.python/python-prettyprint.exp
index f83b1cd..907dcfd 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/python-prettyprint.exp
@@ -85,6 +85,8 @@ proc run_lang_tests {lang} {
 
     gdb_test "print c" " = container $hex \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
 
+    gdb_test "print nullstr" "RuntimeError: Error reading string from inferior.*"
+
     gdb_test "continue" "Program exited normally\."
 }
 
diff --git a/gdb/testsuite/gdb.python/python-prettyprint.py b/gdb/testsuite/gdb.python/python-prettyprint.py
index a53e412..82e5331 100644
--- a/gdb/testsuite/gdb.python/python-prettyprint.py
+++ b/gdb/testsuite/gdb.python/python-prettyprint.py
@@ -92,6 +92,13 @@ class pp_vbase1:
     def to_string (self):
         return "pp class name: " + self.val.type.tag
 
+class pp_nullstr:
+    def __init__(self, val):
+        self.val = val
+
+    def to_string(self):
+        return self.val['s'].string(gdb.parameter('target-charset'))
+
 def lookup_function (val):
     "Look-up and return a pretty-printer that can print val."
 
@@ -135,6 +142,9 @@ def register_pretty_printers ():
     
     pretty_printers_dict[re.compile ('^VirtualTest$')] =  pp_multiple_virtual
     pretty_printers_dict[re.compile ('^Vbase1$')] =  pp_vbase1
+
+    pretty_printers_dict[re.compile ('^struct nullstr$')] = pp_nullstr
+    pretty_printers_dict[re.compile ('^nullstr$')] = pp_nullstr
     
     # Note that we purposely omit the typedef names here.
     # Printer lookup is based on canonical name.


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


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

only message in thread, other threads:[~2009-04-15 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-15 11:58 [SCM] archer-tromey-python: Testcase for a crash in c_get_string 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).