You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
4.9 KiB
137 lines
4.9 KiB
6 years ago
|
NOTE: This patch has been forwardported from RHEL-6.7.
|
||
|
|
||
|
URL: <https://sourceware.org/ml/gdb-patches/2013-05/msg00364.html>
|
||
|
Message-ID: <1368136582.30058.7.camel@soleil>
|
||
|
|
||
|
From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
|
||
|
To: gdb-patches at sourceware dot org
|
||
|
Subject: RFA: fix gdb_assert caused by 'catch signal ...' and fork
|
||
|
Date: Thu, 09 May 2013 23:56:22 +0200
|
||
|
|
||
|
The attached patch fixes a gdb_assert caused by the combination of catch
|
||
|
signal and fork:
|
||
|
break-catch-sig.c:152: internal-error: signal_catchpoint_remove_location: Assertion `signal_catch_counts[iter] > 0' failed.
|
||
|
|
||
|
The problem is that the signal_catch_counts is decremented by detach_breakpoints.
|
||
|
The fix consists in not detaching breakpoint locations of type bp_loc_other.
|
||
|
The patch introduces a new test.
|
||
|
|
||
|
Comments by Sergio Durigan Junior:
|
||
|
|
||
|
I addded a specific testcase for this patch, which tests exactly the
|
||
|
issue that the customer is facing. This patch does not solve the
|
||
|
whole problem of catching a syscall and forking (for more details,
|
||
|
see <https://sourceware.org/bugzilla/show_bug.cgi?id=13457>,
|
||
|
specifically comment #3), but it solves the issue reported by the
|
||
|
customer.
|
||
|
|
||
|
I also removed the original testcase of this patch, because it
|
||
|
relied on "catch signal", which is a command that is not implemented
|
||
|
in this version of GDB.
|
||
|
|
||
|
commit bd9673a4ded96ea5c108601501c8e59003ea1be6
|
||
|
Author: Philippe Waroquiers <philippe@sourceware.org>
|
||
|
Date: Tue May 21 18:47:05 2013 +0000
|
||
|
|
||
|
Fix internal error caused by interaction between catch signal and fork
|
||
|
|
||
|
Index: gdb-7.6.1/gdb/breakpoint.c
|
||
|
===================================================================
|
||
|
--- gdb-7.6.1.orig/gdb/breakpoint.c
|
||
|
+++ gdb-7.6.1/gdb/breakpoint.c
|
||
|
@@ -3542,6 +3542,15 @@ detach_breakpoints (ptid_t ptid)
|
||
|
if (bl->pspace != inf->pspace)
|
||
|
continue;
|
||
|
|
||
|
+ /* This function must physically remove breakpoints locations
|
||
|
+ from the specified ptid, without modifying the breakpoint
|
||
|
+ package's state. Locations of type bp_loc_other are only
|
||
|
+ maintained at GDB side. So, there is no need to remove
|
||
|
+ these bp_loc_other locations. Moreover, removing these
|
||
|
+ would modify the breakpoint package's state. */
|
||
|
+ if (bl->loc_type == bp_loc_other)
|
||
|
+ continue;
|
||
|
+
|
||
|
if (bl->inserted)
|
||
|
val |= remove_breakpoint_1 (bl, mark_inserted);
|
||
|
}
|
||
|
Index: gdb-7.6.1/gdb/testsuite/gdb.base/gdb-rhbz1149207-catch-syscall-fork.c
|
||
|
===================================================================
|
||
|
--- /dev/null
|
||
|
+++ gdb-7.6.1/gdb/testsuite/gdb.base/gdb-rhbz1149207-catch-syscall-fork.c
|
||
|
@@ -0,0 +1,11 @@
|
||
|
+#include <stdio.h>
|
||
|
+#include <unistd.h>
|
||
|
+
|
||
|
+int
|
||
|
+main (int argc, char **argv)
|
||
|
+{
|
||
|
+ if (fork () == 0)
|
||
|
+ sleep (1);
|
||
|
+ chdir (".");
|
||
|
+ return 0;
|
||
|
+}
|
||
|
Index: gdb-7.6.1/gdb/testsuite/gdb.base/gdb-rhbz1149207-catch-syscall-fork.exp
|
||
|
===================================================================
|
||
|
--- /dev/null
|
||
|
+++ gdb-7.6.1/gdb/testsuite/gdb.base/gdb-rhbz1149207-catch-syscall-fork.exp
|
||
|
@@ -0,0 +1,58 @@
|
||
|
+# Copyright 2015 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/>.
|
||
|
+
|
||
|
+if { [is_remote target] || ![isnative] } then {
|
||
|
+ continue
|
||
|
+}
|
||
|
+
|
||
|
+set testfile "gdb-rhbz1149207-catch-syscall-fork"
|
||
|
+set srcfile ${testfile}.c
|
||
|
+set binfile ${objdir}/${subdir}/${testfile}
|
||
|
+
|
||
|
+# Until "catch syscall" is implemented on other targets...
|
||
|
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
|
||
|
+ continue
|
||
|
+}
|
||
|
+
|
||
|
+# This shall be updated whenever 'catch syscall' is implemented
|
||
|
+# on some architecture.
|
||
|
+#if { ![istarget "i\[34567\]86-*-linux*"]
|
||
|
+if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
|
||
|
+ && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"]
|
||
|
+ && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] } {
|
||
|
+ continue
|
||
|
+}
|
||
|
+
|
||
|
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||
|
+ untested ${testfile}.exp
|
||
|
+ return -1
|
||
|
+}
|
||
|
+
|
||
|
+gdb_exit
|
||
|
+gdb_start
|
||
|
+gdb_reinitialize_dir $srcdir/$subdir
|
||
|
+gdb_load $binfile
|
||
|
+
|
||
|
+if { ![runto_main] } {
|
||
|
+ return -1
|
||
|
+}
|
||
|
+
|
||
|
+gdb_test "catch syscall chdir" \
|
||
|
+ "Catchpoint $decimal \\\(syscall (.)?chdir(.)? \\\[$decimal\\\]\\\)" \
|
||
|
+ "catch syscall chdir"
|
||
|
+
|
||
|
+gdb_test "continue" \
|
||
|
+ "Continuing\.\r\n.*\r\nCatchpoint $decimal \\\(call to syscall .?chdir.?.*" \
|
||
|
+ "continue from catch syscall after fork"
|