+2015-01-09 Pedro Alves <palves@redhat.com>
+
+ * linux-nat.c (lin_lwp_attach_lwp): Assert that the lwp id we're
+ about to wait for is > 0.
+ * linux-thread-db.c (find_new_threads_callback): Ignore thread if
+ the kernel thread ID is -1.
+
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-nat.c (attach_proc_task_lwp_callback): New function.
+2015-01-09 Pedro Alves <palves@redhat.com>
+
+ * thread-db.c (find_new_threads_callback): Ignore thread if the
+ kernel thread ID is -1.
+
2015-01-09 Pedro Alves <palves@redhat.com>
* linux-low.c (linux_attach_fail_reason_string): Move to
if (err != TD_OK)
error ("Cannot get thread info: %s", thread_db_err_str (err));
+ if (ti.ti_lid == -1)
+ {
+ /* A thread with kernel thread ID -1 is either a thread that
+ exited and was joined, or a thread that is being created but
+ hasn't started yet, and that is reusing the tcb/stack of a
+ thread that previously exited and was joined. (glibc marks
+ terminated and joined threads with kernel thread ID -1. See
+ glibc PR17707. */
+ return 0;
+ }
+
/* Check for zombies. */
if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE)
return 0;
/* See if we've got a stop for this new child
pending. If so, we're already attached. */
+ gdb_assert (lwpid > 0);
new_pid = my_waitpid (lwpid, &status, WNOHANG);
if (new_pid == -1 && errno == ECHILD)
new_pid = my_waitpid (lwpid, &status, __WCLONE | WNOHANG);
error (_("find_new_threads_callback: cannot get thread info: %s"),
thread_db_err_str (err));
+ if (ti.ti_lid == -1)
+ {
+ /* A thread with kernel thread ID -1 is either a thread that
+ exited and was joined, or a thread that is being created but
+ hasn't started yet, and that is reusing the tcb/stack of a
+ thread that previously exited and was joined. (glibc marks
+ terminated and joined threads with kernel thread ID -1. See
+ glibc PR17707. */
+ return 0;
+ }
+
if (ti.ti_tid == 0)
{
/* A thread ID of zero means that this is the main thread, but