Bug 1149205 - `catch syscall' doesn't work for parent after `fork' is called
Summary: `catch syscall' doesn't work for parent after `fork' is called
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gdb
Version: 6.4
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: Sergio Durigan Junior
QA Contact: Miroslav Franc
Depends On:
Blocks: 1149207
TreeView+ depends on / blocked
Reported: 2014-10-03 13:59 UTC by Paulo Andrade
Modified: 2018-12-09 18:45 UTC (History)
5 users (show)

Fixed In Version: gdb-7.2-78.el6
Doc Type: Bug Fix
Doc Text:
Cause: The "catch syscall" command uses a special type of breakpoint inside GDB, which is not maintained by the regular code that handles normal breakpoints. However, GDB was incorrectly removing these system call catchpoints when the program being debugged forked itself, which made GDB miss any subsequent system call that needed to be caught. Consequence: GDB would not be able to properly catch a system call in the parent process after a call to "fork". Fix: The fix consists in not removing a system call catchpoint from a program that forked itself. Result: GDB is now able to correctly stop at a system call that is called from the parent process after it has forked.
Clone Of:
Last Closed: 2015-07-22 06:34:24 UTC
Target Upstream Version:

Attachments (Terms of Use)
test-catch-mprotect.c (1.03 KB, text/x-csrc)
2014-10-03 14:27 UTC, Paulo Andrade
no flags Details

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1325 0 normal SHIPPED_LIVE gdb bug fix update 2015-07-20 17:53:09 UTC

Description Paulo Andrade 2014-10-03 13:59:46 UTC

This problem does not happen in fedora 20:

$ rpm -q gdb

but happens in rhel-6.4 (after updates):

$ rpm -q gdb

and also happens in rhel-7:

$ rpm -q gdb

Comment 2 Paulo Andrade 2014-10-03 14:27:23 UTC
Created attachment 943729 [details]

I created this simple test before opening the bug report.
Compile it as:

$ gcc -pthead -O0 -g3 -o test-catch-mprotect test-catch-mprotect.c

The original problem report is gdb not catch'ing mprotect.

The test program accepts "-t" to run mprotect in a new thread,
"-f" after fork, or by default in a simple test routine.

But to actually test the reported problem, it suffices to run
the simple test in the sourceware bug report, as the more complete
test case, added here for extra information, only triggers the
problem for fork. Anyway, example of use:

$ gdb test-catch-mprotect
(gdb) b main
(gdb) r -f
(gdb) catch syscall mprotect
(gdb) c

if not also executing:

(gdb) set fork-follow-mode child

it will not stop in mprotect for the affected systems.
So far only confirmed to work in fedora 20 (but mosy likely
will work on newer fedora).

Comment 3 Sergio Durigan Junior 2014-10-03 20:09:26 UTC
Moving to 6.7.0.

Comment 7 errata-xmlrpc 2015-07-22 06:34:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.