rpms/gdb/devel gdb-c_get_string-xfree.patch, NONE, 1.1 gdb.spec, 1.342, 1.343

Jan Kratochvil jkratoch at fedoraproject.org
Tue Apr 14 22:18:29 UTC 2009


Author: jkratoch

Update of /cvs/pkgs/rpms/gdb/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv14888

Modified Files:
	gdb.spec 
Added Files:
	gdb-c_get_string-xfree.patch 
Log Message:
* Wed Apr 15 2009 Jan Kratochvil <jan.kratochvil at redhat.com> - 6.8.50.20090302-19
- Fix crash on pretty-printer reading uninitialized std::string (BZ 495781).


gdb-c_get_string-xfree.patch:

--- NEW FILE gdb-c_get_string-xfree.patch ---
http://sourceware.org/ml/gdb-patches/2009-04/msg00284.html
http://sourceware.org/ml/gdb-cvs/2009-04/msg00077.html
http://sourceware.org/ml/archer/2009-q2/msg00049.html

gdb/
2009-04-14  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* c-lang.c (c_get_string): Fix xfree crash on a failed string read.

gdb/testsuite/
2009-04-14  Jan Kratochvil  <jan.kratochvil at 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'.

--- src/gdb/c-lang.c	2009/03/21 00:46:17	1.63
+++ src/gdb/c-lang.c	2009/04/14 21:54:33	1.64
@@ -657,7 +657,7 @@
 			 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.


Index: gdb.spec
===================================================================
RCS file: /cvs/pkgs/rpms/gdb/devel/gdb.spec,v
retrieving revision 1.342
retrieving revision 1.343
diff -u -r1.342 -r1.343
--- gdb.spec	13 Apr 2009 21:25:31 -0000	1.342
+++ gdb.spec	14 Apr 2009 22:17:59 -0000	1.343
@@ -13,7 +13,7 @@
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 18%{?_with_upstream:.upstream}%{?dist}
+Release: 19%{?_with_upstream:.upstream}%{?dist}
 
 License: GPLv3+
 Group: Development/Debuggers
@@ -375,6 +375,9 @@
 # - Turn on 64-bit BFD support, globally enable AC_SYS_LARGEFILE.
 Patch352: gdb-6.8-bz457187-largefile.patch
 
+# Fix crash on pretty-printer reading uninitialized std::string (BZ 495781).
+Patch357: gdb-c_get_string-xfree.patch
+
 BuildRequires: ncurses-devel texinfo gettext flex bison expat-devel
 Requires: readline
 BuildRequires: readline-devel
@@ -569,6 +572,7 @@
 %patch343 -p1
 %patch348 -p1
 %patch352 -p1
+%patch357 -p1
 %patch124 -p1
 
 find -name "*.orig" | xargs rm -f
@@ -851,6 +855,9 @@
 %endif
 
 %changelog
+* Wed Apr 15 2009 Jan Kratochvil <jan.kratochvil at redhat.com> - 6.8.50.20090302-19
+- Fix crash on pretty-printer reading uninitialized std::string (BZ 495781).
+
 * Mon Apr 13 2009 Jan Kratochvil <jan.kratochvil at redhat.com> - 6.8.50.20090302-18
 - Archer update to the snapshot: d1fee5066408a09423621d1ebc64e6d3e248ed08
 - Archer backport: 4854339f75bdaf4b228fc35579bddbb2a1fecdc1




More information about the fedora-extras-commits mailing list