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