diff --git a/gdb-c_get_string-xfree.patch b/gdb-c_get_string-xfree.patch new file mode 100644 index 0000000..00703b5 --- /dev/null +++ b/gdb-c_get_string-xfree.patch @@ -0,0 +1,110 @@ +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 + + * c-lang.c (c_get_string): Fix xfree crash on a failed string read. + +gdb/testsuite/ +2009-04-14 Jan Kratochvil + + * gdb.python/python-prettyprint.c: Include . + (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 . */ + ++#include ++ + 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. diff --git a/gdb.spec b/gdb.spec index 7fda137..3d8903a 100644 --- a/gdb.spec +++ b/gdb.spec @@ -13,7 +13,7 @@ Version: 6.8.50.20090302 # 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 @@ Patch349: gdb-archer.patch # - 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 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch343 -p1 %patch348 -p1 %patch352 -p1 +%patch357 -p1 %patch124 -p1 find -name "*.orig" | xargs rm -f @@ -851,6 +855,9 @@ fi %endif %changelog +* Wed Apr 15 2009 Jan Kratochvil - 6.8.50.20090302-19 +- Fix crash on pretty-printer reading uninitialized std::string (BZ 495781). + * Mon Apr 13 2009 Jan Kratochvil - 6.8.50.20090302-18 - Archer update to the snapshot: d1fee5066408a09423621d1ebc64e6d3e248ed08 - Archer backport: 4854339f75bdaf4b228fc35579bddbb2a1fecdc1