Skip to content

Commit bd9673a

Browse files
author
Philippe Waroquiers
committed
Fix internal error caused by interaction between catch signal and fork
1 parent 69a9759 commit bd9673a

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

gdb/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2013-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
2+
3+
* breakpoints.c (detach_breakpoints): Do not
4+
detach breakpoints locations with loc_type bp_loc_other.
5+
16
2013-05-21 Jan Kratochvil <jan.kratochvil@redhat.com>
27

38
Workaround Python 2.6.

gdb/breakpoint.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,6 +3537,15 @@ detach_breakpoints (ptid_t ptid)
35373537
if (bl->pspace != inf->pspace)
35383538
continue;
35393539

3540+
/* This function must physically remove breakpoints locations
3541+
from the specified ptid, without modifying the breakpoint
3542+
package's state. Locations of type bp_loc_other are only
3543+
maintained at GDB side. So, there is no need to remove
3544+
these bp_loc_other locations. Moreover, removing these
3545+
would modify the breakpoint package's state. */
3546+
if (bl->loc_type == bp_loc_other)
3547+
continue;
3548+
35403549
if (bl->inserted)
35413550
val |= remove_breakpoint_1 (bl, mark_inserted);
35423551
}

gdb/testsuite/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2013-05-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
2+
3+
* gdb.base/catch-signal-fork.exp: New file.
4+
* gdb.base/catch-signal-fork.c: New file.
5+
16
2013-05-21 Sterling Augustine <saugustine@google.com>
27

38
* boards/remote-stdio-gdbserver.exp: New file.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* This testcase is part of GDB, the GNU debugger.
2+
3+
Copyright 2012-2013 Free Software Foundation, Inc.
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
17+
#include <stdlib.h>
18+
#include <signal.h>
19+
#include <unistd.h>
20+
21+
void
22+
do_nothing (void)
23+
{
24+
}
25+
26+
void
27+
handle (int sig)
28+
{
29+
do_nothing (); /* handle marker */
30+
}
31+
32+
int
33+
main ()
34+
{
35+
int i;
36+
signal (SIGHUP, handle);
37+
38+
raise (SIGHUP); /* first HUP */
39+
40+
signal (SIGCHLD, handle);
41+
for (i = 0; i < 3; i++) /* fork loop */
42+
{
43+
switch (fork())
44+
{
45+
case -1:
46+
perror ("fork");
47+
exit (1);
48+
case 0:
49+
exit (0);
50+
}
51+
wait (NULL);
52+
}
53+
54+
raise (SIGHUP); /* second HUP */
55+
56+
raise (SIGHUP); /* third HUP */
57+
}
58+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2012-2013 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 [target_info exists gdb,nosignals] {
17+
verbose "Skipping catch-signal-fork.exp because of nosignals."
18+
continue
19+
}
20+
21+
standard_testfile
22+
23+
if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
24+
return -1
25+
}
26+
27+
if {![runto_main]} {
28+
return -1
29+
}
30+
31+
# Test "catch signal SIGHUP"
32+
gdb_test "catch signal SIGHUP" "Catchpoint .*"
33+
gdb_breakpoint ${srcfile}:[gdb_get_line_number "first HUP"]
34+
gdb_breakpoint ${srcfile}:[gdb_get_line_number "fork loop"]
35+
36+
gdb_continue_to_breakpoint "first HUP"
37+
gdb_test "continue" "Catchpoint .*"
38+
39+
# Test interaction with fork.
40+
# This used to cause a gdb_assert in the code detaching the
41+
# breakpoints for the child.
42+
gdb_continue_to_breakpoint "fork loop"
43+
gdb_test "continue" "Catchpoint .* SIGHUP.*" "got SIGHUP after fork"

0 commit comments

Comments
 (0)