Skip to content

Commit aaea2ab

Browse files
ivanivanov884jeffmahoney
authored andcommitted
gdb-rhbz1149205-catch-syscall-after-fork-test.patch
;; Fix '`catch syscall' doesn't work for parent after `fork' is called' ;; (Philippe Waroquiers, RH BZ 1149205). ;;=fedoratest 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 bd9673a Author: Philippe Waroquiers <[email protected]> Date: Tue May 21 18:47:05 2013 +0000 Fix internal error caused by interaction between catch signal and fork
1 parent 6076039 commit aaea2ab

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#include <unistd.h>
3+
4+
int
5+
main (int argc, char **argv)
6+
{
7+
if (fork () == 0)
8+
sleep (1);
9+
chdir (".");
10+
return 0;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2015 Free Software Foundation, Inc.
2+
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
if { [is_remote target] || ![isnative] } then {
17+
continue
18+
}
19+
20+
set testfile "gdb-rhbz1149205-catch-syscall-fork"
21+
set srcfile ${testfile}.c
22+
set binfile [standard_output_file ${testfile}]
23+
24+
# Until "catch syscall" is implemented on other targets...
25+
if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
26+
continue
27+
}
28+
29+
# This shall be updated whenever 'catch syscall' is implemented
30+
# on some architecture.
31+
#if { ![istarget "i\[34567\]86-*-linux*"]
32+
if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
33+
&& ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"]
34+
&& ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] } {
35+
continue
36+
}
37+
38+
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39+
untested ${testfile}.exp
40+
return -1
41+
}
42+
43+
gdb_exit
44+
gdb_start
45+
gdb_reinitialize_dir $srcdir/$subdir
46+
gdb_load $binfile
47+
48+
if { ![runto_main] } {
49+
return -1
50+
}
51+
52+
gdb_test "catch syscall chdir" \
53+
"Catchpoint $decimal \\\(syscall (.)?chdir(.)? \\\[$decimal\\\]\\\)" \
54+
"catch syscall chdir"
55+
56+
gdb_test "continue" \
57+
"Continuing\.\r\n.*\r\nCatchpoint $decimal \\\(call to syscall .?chdir.?.*" \
58+
"continue from catch syscall after fork"

0 commit comments

Comments
 (0)