This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/19494] hang killing unfollowed fork children


https://sourceware.org/bugzilla/show_bug.cgi?id=19494

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1d2736d43ba16c585e643faec4b6a5084d782289

commit 1d2736d43ba16c585e643faec4b6a5084d782289
Author: Pedro Alves <palves@redhat.com>
Date:   Mon Jan 25 12:00:20 2016 +0000

    Fix PR 19494: hang when killing unfollowed fork children

    linux_nat_kill relies on get_last_target_status to determine whether
    the current inferior is stopped at a unfollowed fork/vfork event.
    This is bad because many things can happen ever since we caught the
    fork/vfork event...  This commit rewrites that code to instead walk
    the thread list looking for unfollowed fork events, similarly to what
    was done for remote.c.

    New test included.  The main idea of the test is make sure that when
    the program stops for a fork catchpoint, and the user kills the
    parent, gdb also kills the unfollowed fork child.  Since the child
    hasn't been added as an inferior at that point, we need some other
    portable way to detect that the child is gone.  The test uses a pipe
    for that.  The program forks twice, so you have grandparent, child and
    grandchild.  The grandchild inherits the write side of the pipe.  The
    grandparent hangs reading from the pipe, since nothing ever writes to
    it.  If, when GDB kills the child, it also kills the grandchild, then
    the grandparent's pipe read returns 0/EOF and the test passes.
    Otherwise, if GDB doesn't kill the grandchild, then the pipe read
    never returns and the test times out, like:

     FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork:
kill parent (timeout)
     FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill:
vfork: kill parent (timeout)

    No regressions on x86_64 Fedora 20.  New test passes with gdbserver as
    well.

    gdb/ChangeLog:
    2016-01-25  Pedro Alves  <palves@redhat.com>

        PR gdb/19494
        * linux-nat.c (kill_one_lwp): New, factored out from ...
        (kill_callback): ... this.
        (kill_wait_callback): New, factored out from ...
        (kill_wait_one_lwp): ... this.
        (kill_unfollowed_fork_children): New function.
        (linux_nat_kill): Use it.

    gdb/testsuite/ChangeLog:
    2016-01-25  Pedro Alves  <palves@redhat.com>

        PR gdb/19494
        * gdb.base/catch-fork-kill.c: New file.
        * gdb.base/catch-fork-kill.exp: New file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]