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 threads/18600] After forking and threads spawning, gdb leaves newly created threads stopped


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

--- Comment #2 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=4dd63d488a76482543517c4c4cde699ee6fa33ef

commit 4dd63d488a76482543517c4c4cde699ee6fa33ef
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Jul 30 18:50:29 2015 +0100

    PR threads/18600: Threads left stopped after fork+thread spawn

    When a program forks and another process start threads while gdb is
    handling the fork event, newly created threads are left stuck stopped
    by gdb, even though gdb presents them as "running", to the user.

    This can be seen with the test added by this patch.  The test has the
    inferior fork a certain number of times and waits for all children to
    exit.  Each fork child spawns a number of threads that do nothing and
    joins them immediately.  Normally, the program should run unimpeded
    (from the point of view of the user) and exit very quickly.  Without
    this fix, it doesn't because of some threads left stopped by gdb, so
    inferior 1 never exits.

    The program triggers when a new clone thread is found while inside the
    linux_stop_and_wait_all_lwps call in linux-thread-db.c:

          linux_stop_and_wait_all_lwps ();

          ALL_LWPS (lp)
        if (ptid_get_pid (lp->ptid) == pid)
          thread_from_lwp (lp->ptid);

          linux_unstop_all_lwps ();

    Within linux_stop_and_wait_all_lwps, we reach
    linux_handle_extended_wait with the "stopping" parameter set to 1, and
    because of that we don't mark the new lwp as resumed.  As consequence,
    the subsequent resume_stopped_resumed_lwps, called from
    linux_unstop_all_lwps, never resumes the new LWP.

    There's lots of cruft in linux_handle_extended_wait that no longer
    makes sense.  On systems with CLONE events support, we don't rely on
    libthread_db for thread listing anymore, so the code that preserves
    stop_requested and the handling of last_resume_kind is all dead.

    So the fix is to remove all that, and simply always mark the new LWP
    as resumed, so that resume_stopped_resumed_lwps re-resumes it.

    gdb/ChangeLog:
    2015-07-30  Pedro Alves  <palves@redhat.com>
            Simon Marchi  <simon.marchi@ericsson.com>

        PR threads/18600
        * linux-nat.c (linux_handle_extended_wait): On CLONE event, always
        mark the new thread as resumed.  Remove STOPPING parameter.
        (wait_lwp): Adjust call to linux_handle_extended_wait.
        (linux_nat_filter_event): Adjust call to
        linux_handle_extended_wait.
        (resume_stopped_resumed_lwps): Add debug output.

    gdb/testsuite/ChangeLog:
    2015-07-30  Simon Marchi  <simon.marchi@ericsson.com>
            Pedro Alves  <palves@redhat.com>

        PR threads/18600
        * gdb.threads/fork-plus-threads.c: New file.
        * gdb.threads/fork-plus-threads.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]