[gdb/f14/master] - python: load *-gdb.py for shlibs during attach (BZ 634660). - Fix double free crash during overloa

Jan Kratochvil jkratoch at fedoraproject.org
Wed Sep 22 09:19:57 UTC 2010


commit 74d8b422e587001ded06681cbd79b91cfb5ed171
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Wed Sep 22 11:19:50 2010 +0200

    - python: load *-gdb.py for shlibs during attach (BZ 634660).
    - Fix double free crash during overload resolution (PR 12028, Sami Wagiaalla).

 gdb-bz634660-gdbpy-load-on-attach.patch |   61 +++++++++++++++++++
 gdb-pr12028-double-free.patch           |   99 +++++++++++++++++++++++++++++++
 gdb.spec                                |   14 ++++-
 3 files changed, 173 insertions(+), 1 deletions(-)
---
diff --git a/gdb-bz634660-gdbpy-load-on-attach.patch b/gdb-bz634660-gdbpy-load-on-attach.patch
new file mode 100644
index 0000000..2223776
--- /dev/null
+++ b/gdb-bz634660-gdbpy-load-on-attach.patch
@@ -0,0 +1,61 @@
+http://sourceware.org/ml/gdb-patches/2010-09/msg00365.html
+Subject: [patch] python: load *-gdb.py for shlibs during attach
+
+Hi,
+
+currently if you attach to or load a core file for executable, its -gdb.py
+script is loaded.  But none -gdb.py for the shared libraries.
+
+Spawned or with the fix (libstdc++-gdb.py):
+#1  0x00000000004007b5 in f (s="a") at 1.C:4
+                             ^ is std::string
+
+Attached/core without the fix:
+#1  0x00000000004007b5 in f (s=...) at 1.C:4
+
+No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
+
+Mostly obvious, I will check it in later.
+
+
+Thanks,
+Jan
+
+
+gdb/
+2010-09-22  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	* main.c: Include objfiles.h.
+	(captured_main): New variable objfile.  Call
+	load_auto_scripts_for_objfile for ALL_OBJFILES.
+
+--- ./gdb/main.c	2010-09-22 10:51:32.000000000 +0200
++++ ./gdb/main.c	2010-09-22 10:50:44.000000000 +0200
+@@ -43,6 +43,7 @@
+ #include "source.h"
+ #include "cli/cli-cmds.h"
+ #include "python/python.h"
++#include "objfiles.h"
+ 
+ /* The selected interpreter.  This will be used as a set command
+    variable, so it should always be malloc'ed - since
+@@ -323,6 +324,7 @@ captured_main (void *data)
+ 
+   int i;
+   int save_auto_load;
++  struct objfile *objfile;
+ 
+   struct cleanup *pre_stat_chain = make_command_stats_cleanup (0);
+ 
+@@ -957,8 +959,8 @@ Can't attach to process and specify a co
+      We wait until now because it is common to add to the source search
+      path in local_gdbinit.  */
+   gdbpy_global_auto_load = save_auto_load;
+-  if (symfile_objfile != NULL)
+-    load_auto_scripts_for_objfile (symfile_objfile);
++  ALL_OBJFILES (objfile)
++    load_auto_scripts_for_objfile (objfile);
+ 
+   for (i = 0; i < ncmd; i++)
+     {
+
diff --git a/gdb-pr12028-double-free.patch b/gdb-pr12028-double-free.patch
new file mode 100644
index 0000000..deb2115
--- /dev/null
+++ b/gdb-pr12028-double-free.patch
@@ -0,0 +1,99 @@
+http://sourceware.org/ml/gdb-patches/2010-09/msg00321.html
+Subject: [patch] PR 12028 "GDB crashes on a double free during overload resolution"
+
+old_cleanups was being set twice making the later call to 
+discard_cleanups ignore the first 'make_cleanup' request.
+
+The patch is proposed for both head and the 7.2 branch.
+
+This has been regression tested on x8664 with gcc-4.4.4-10.fc13
+
+
+Fix PR 12028: "GDB crashes on a double free during overload resolution "
+
+2010-09-16  Sami Wagiaalla  <swagiaal at redhat.com>
+
+	PR C++/12028
+	* valops.c (find_oload_champ_namespace_loop): removed incorrect
+	'old_cleanups' reassignment.
+
+2010-09-16  Sami Wagiaalla  <swagiaal at redhat.com>
+
+	* gdb.cp/pr12028.cc: New.
+	* gdb.cp/pr12028.exp: New.
+
+diff --git a/gdb/testsuite/gdb.cp/pr12028.cc b/gdb/testsuite/gdb.cp/pr12028.cc
+new file mode 100644
+index 0000000..0fcab6b
+--- /dev/null
++++ b/gdb/testsuite/gdb.cp/pr12028.cc
+@@ -0,0 +1,21 @@
++class A{};
++class B{};
++class C: public B {};
++
++namespace D{
++  int foo (A) { return 11; }
++  int foo (C) { return 12; }
++}
++
++int main()
++{
++  A a;
++  B b;
++  C c;
++
++  D::foo (a);
++  //  D::foo (b);
++  D::foo (c);
++
++  return 0;
++}
+diff --git a/gdb/testsuite/gdb.cp/pr12028.exp b/gdb/testsuite/gdb.cp/pr12028.exp
+new file mode 100644
+index 0000000..746c6b5
+--- /dev/null
++++ b/gdb/testsuite/gdb.cp/pr12028.exp
+@@ -0,0 +1,29 @@
++# Copyright 2008 Free Software Foundation, Inc.
++
++# This program is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation; either version 3 of the License, or
++# (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
++
++set testfile pr12028
++set srcfile ${testfile}.cc
++if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
++    return -1
++}
++
++############################################
++
++if ![runto_main] then {
++    perror "couldn't run to breakpoint main"
++    continue
++}
++
++gdb_test "p D::foo(b)" "Cannot resolve function foo to any overloaded instance"
+diff --git a/gdb/valops.c b/gdb/valops.c
+index 7fbad10..4e83a04 100644
+--- a/gdb/valops.c
++++ b/gdb/valops.c
+@@ -2715,7 +2715,7 @@ find_oload_champ_namespace_loop (struct type **arg_types, int nargs,
+      function symbol to start off with.)  */
+ 
+   old_cleanups = make_cleanup (xfree, *oload_syms);
+-  old_cleanups = make_cleanup (xfree, *oload_champ_bv);
++  make_cleanup (xfree, *oload_champ_bv);
+   new_namespace = alloca (namespace_len + 1);
+   strncpy (new_namespace, qualified_name, namespace_len);
+   new_namespace[namespace_len] = '\0';
diff --git a/gdb.spec b/gdb.spec
index 40fb0e7..9f98158 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -38,7 +38,7 @@ Version: 7.2
 
 # 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: 6%{?_with_upstream:.upstream}%{dist}
+Release: 7%{?_with_upstream:.upstream}%{dist}
 
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
 Group: Development/Debuggers
@@ -440,6 +440,12 @@ Patch500: gdb-bz631158-cxx-this-lookup.patch
 # Fix Ada regression when any .gdb_index library is present.
 Patch501: gdb-gdbindex-ada-regression.patch
 
+# python: load *-gdb.py for shlibs during attach (BZ 634660).
+Patch502: gdb-bz634660-gdbpy-load-on-attach.patch
+
+# Fix double free crash during overload resolution (PR 12028, Sami Wagiaalla).
+Patch503: gdb-pr12028-double-free.patch
+
 BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
 Requires: readline%{?_isa}
 BuildRequires: readline-devel%{?_isa}
@@ -697,6 +703,8 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
 %patch499 -p1
 %patch500 -p1
 %patch501 -p1
+%patch502 -p1
+%patch503 -p1
 
 %patch393 -p1
 %patch335 -p1
@@ -1081,6 +1089,10 @@ fi
 %endif
 
 %changelog
+* Wed Sep 22 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-7.fc14
+- python: load *-gdb.py for shlibs during attach (BZ 634660).
+- Fix double free crash during overload resolution (PR 12028, Sami Wagiaalla).
+
 * Sat Sep 18 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-6.fc14
 - Fix python gdb.solib_address (BZ 634108, fix by Phil Muldoon).
 - Temporarily build with -O0 to workaround GCC BZ 634757 (cmove bug).


More information about the scm-commits mailing list