Skip to content

Commit

Permalink
gdb-rhbz1149205-catch-syscall-after-fork-test.patch
Browse files Browse the repository at this point in the history
;; 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
  • Loading branch information
ivanivanov884 authored and jeffmahoney committed Apr 14, 2019
1 parent b2a93bb commit 37f9d02
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>
#include <unistd.h>

int
main (int argc, char **argv)
{
if (fork () == 0)
sleep (1);
chdir (".");
return 0;
}
58 changes: 58 additions & 0 deletions gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp
Original file line number Diff line number Diff line change
@@ -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-rhbz1149205-catch-syscall-fork"
set srcfile ${testfile}.c
set binfile [standard_output_file ${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"

0 comments on commit 37f9d02

Please sign in to comment.