Bug 1149205

Summary: `catch syscall' doesn't work for parent after `fork' is called
Product: Red Hat Enterprise Linux 6 Reporter: Paulo Andrade <pandrade>
Component: gdbAssignee: Sergio Durigan Junior <sergiodj>
Status: CLOSED ERRATA QA Contact: Miroslav Franc <mfranc>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4CC: gdb-bugs, jan.kratochvil, mcermak, mfranc, ohudlick
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 06:34:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1149207    
Attachments:
Description Flags
test-catch-mprotect.c none

Description Paulo Andrade 2014-10-03 13:59:46 UTC
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

Comment 2 Paulo Andrade 2014-10-03 14:27:23 UTC
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 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.

https://rhn.redhat.com/errata/RHBA-2015-1325.html