From ec32282347dc5dbd1d58cbc16427e2e24ca6b14c Mon Sep 17 00:00:00 2001 From: Sami Wagiaalla Date: Wed, 22 Sep 2010 15:48:59 +0000 Subject: [PATCH] Fix PR 12028: "GDB crashes on a double free during overload resolution " 2010-09-22 Sami Wagiaalla PR C++/12028 * valops.c (find_oload_champ_namespace_loop): removed incorrect 'old_cleanups' reassignment. 2010-09-22 Sami Wagiaalla * gdb.cp/pr12028.cc: New. * gdb.cp/pr12028.exp: New. --- gdb/ChangeLog | 6 ++++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.cp/pr12028.cc | 21 +++++++++++++++++++++ gdb/testsuite/gdb.cp/pr12028.exp | 29 +++++++++++++++++++++++++++++ gdb/valops.c | 2 +- 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.cp/pr12028.cc create mode 100644 gdb/testsuite/gdb.cp/pr12028.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9d6b886ac25..69396009612 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2010-09-22 Sami Wagiaalla + + PR C++/12028 + * valops.c (find_oload_champ_namespace_loop): removed incorrect + 'old_cleanups' reassignment. + 2010-09-16 Jan Kratochvil * charset.c (wchar_iterate) : Return any possibly converted diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index fc645fe026e..85a2576a632 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-22 Sami Wagiaalla + + * gdb.cp/pr12028.cc: New. + * gdb.cp/pr12028.exp: New. + 2010-09-16 Phil Muldoon Jan Kratochvil diff --git a/gdb/testsuite/gdb.cp/pr12028.cc b/gdb/testsuite/gdb.cp/pr12028.cc new file mode 100644 index 00000000000..0fcab6b1e93 --- /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 00000000000..746c6b5610e --- /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 . + +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 8150d7ece41..bbbf66e7979 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2713,7 +2713,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'; -- 2.30.2