From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19401 invoked by alias); 17 Aug 2010 18:38:14 -0000 Received: (qmail 19390 invoked by uid 22791); 17 Aug 2010 18:38:13 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Aug 2010 18:38:07 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7HIc5Cc014104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Aug 2010 14:38:05 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7HIc3Dw025992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 17 Aug 2010 14:38:05 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o7HIc3ag028259 for ; Tue, 17 Aug 2010 20:38:03 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o7HIc2vR028258 for gdb-patches@sourceware.org; Tue, 17 Aug 2010 20:38:02 +0200 Date: Tue, 17 Aug 2010 18:38:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] testsuite: new: std::terminate crash Message-ID: <20100817183802.GA28129@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00266.txt.bz2 Hi, this is a testcase for a checked-in fix: Re: RFC: fix bug with std::terminate handler http://sourceware.org/ml/gdb-patches/2010-03/msg00861.html Message-ID: 93ad27bbc56b9c0209d9b49851d538afc80723dd http://sourceware.org/ml/gdb-cvs/2010-03/msg00242.html Tested on {x86_64,x86_64-m32}-fedora14snapshot-linux-gnu. I am not sure how useful it is for FSF GDB but I had to write it anyway. Thanks, Jan gdb/testsuite/ 2010-08-17 Jan Kratochvil * gdb.cp/infcall-dlopen.exp: New file. * gdb.cp/infcall-dlopen.cc: New file. * gdb.cp/infcall-dlopen-lib.cc: New file. --- /dev/null +++ b/gdb/testsuite/gdb.cp/infcall-dlopen-lib.cc @@ -0,0 +1,16 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . */ --- /dev/null +++ b/gdb/testsuite/gdb.cp/infcall-dlopen.cc @@ -0,0 +1,37 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 . */ + +#include +#include + +static int +openlib (const char *filename) +{ + void *h = dlopen (filename, RTLD_LAZY); + + if (h == NULL) + return 0; + if (dlclose (h) != 0) + return 0; + return 1; +} + +int +main (void) +{ + return 0; +} --- /dev/null +++ b/gdb/testsuite/gdb.cp/infcall-dlopen.exp @@ -0,0 +1,46 @@ +# Copyright 2010 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 . + +if {[skip_shlib_tests]} { + return 0 +} + +if [get_compiler_info not-used] { + return -1 +} + +set testfile "infcall-dlopen" +set srcmainfile ${testfile}.cc +set srclibfile ${testfile}-lib.cc +set executable ${testfile} +set libfile ${objdir}/${subdir}/${executable}.so +set binfile ${objdir}/${subdir}/${executable} + +# Use completely arbitrary file for $libfile source. +if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug c++}] != "" + || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug c++ shlib_load}] } { + return -1 +} + +if { ![runto_main] } { + return -1 +} + +for {set i 0} {$i < 10} {incr i} { + gdb_test "p openlib (\"${libfile}\")" " = 1" "test $i" + # Try to exploit the GDB trashed memory. + gdb_test "b openlib" {Breakpoint [0-9]+ at .*} "test $i stub 1" + gdb_test_no_output {delete $bpnum} "" "test $i stub 2" +}