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.
https://sourceware.org/bugzilla/show_bug.cgi?id=13457
This problem does not happen in fedora 20:
$ rpm -q gdb
gdb-7.7.1-18.fc20.x86_64
but happens in rhel-6.4 (after updates):
$ rpm -q gdb
gdb-7.2-64.el6_5.2.x86_64
and also happens in rhel-7:
$ rpm -q gdb
gdb-7.6.1-51-el7.x86_64
Created attachment 943729[details]
test-catch-mprotect.c
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 3Sergio Durigan Junior
2014-10-03 20:09:26 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.
https://rhn.redhat.com/errata/RHBA-2015-1325.html