/* Don't ignore the initial SIGSTOP if we just attached to this
      process.  It will be collected by wait shortly.  */
   initial_thread = find_thread_ptid (ptid_t (pid, pid));
+  gdb_assert (initial_thread != nullptr);
   initial_thread->last_resume_kind = resume_stop;
 
   /* We must attach to every LWP.  If /proc is mounted, use that to
       gdb_assert (lwpid > 0);
 
       lwp = find_lwp_pid (ptid_t (lwpid));
+      gdb_assert (lwp != nullptr);
 
       if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGSTOP)
        {
     });
 
   main_lwp = find_lwp_pid (ptid_t (process->pid));
+  gdb_assert (main_lwp != nullptr);
   detach_one_lwp (main_lwp);
 
   mourn (process);
   else if (filter_ptid != null_ptid)
     {
       requested_child = find_lwp_pid (filter_ptid);
+      gdb_assert (requested_child != nullptr);
 
       if (stopping_threads == NOT_STOPPING_THREADS
          && requested_child->status_pending_p