From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14641 invoked by alias); 1 Mar 2016 16:45:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 13981 invoked by uid 89); 1 Mar 2016 16:45:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=chk, 5647 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 01 Mar 2016 16:45:17 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 688178E3CC for ; Tue, 1 Mar 2016 16:45:16 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u21GjDK2004565 for ; Tue, 1 Mar 2016 11:45:15 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Fix PR gdb/19676: Internal error in linux-thread.db.c if /proc not mounted Date: Tue, 01 Mar 2016 16:45:00 -0000 Message-Id: <1456850713-5745-3-git-send-email-palves@redhat.com> In-Reply-To: <1456850713-5745-1-git-send-email-palves@redhat.com> References: <1456850713-5745-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-03/txt/msg00014.txt.bz2 If /proc is not mounted, GDB fails an assertion in find_new_threads_once: Continuing. /home/pedro/gdb/mygit/src/gdb/linux-thread-db.c:1249: internal-error: find_new_threads_once: Assertion `!target_has_execution' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) That was supposed to catch misuses of td_ta_thr_iter, which is unsafe for live debugging. However, if /proc is not mounted, we still fallback to using it. I didn't bother with a warning, because GDB already prints several others related to failing to open /proc files. gdb/ChangeLog: 2016-03-01 Pedro Alves PR gdb/19676 * linux-thread-db.c (try_thread_db_load_1): Leave info->td_ta_thr_iter_p NULL iff debugging a live process and we have /proc access. (find_new_threads_once): Assert that we have a non-NULL info->td_ta_thr_iter_p instead of checking whether the target has execution. --- gdb/linux-thread-db.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 1eb457d..ce60beb 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -564,7 +564,6 @@ try_thread_db_load_1 (struct thread_db_info *info) /* These are essential. */ CHK (TDB_VERBOSE_DLSYM (info, td_ta_map_lwp2thr)); - CHK (TDB_VERBOSE_DLSYM (info, td_ta_thr_iter)); CHK (TDB_VERBOSE_DLSYM (info, td_thr_validate)); CHK (TDB_VERBOSE_DLSYM (info, td_thr_get_info)); @@ -572,10 +571,6 @@ try_thread_db_load_1 (struct thread_db_info *info) TDB_DLSYM (info, td_thr_tls_get_addr); TDB_DLSYM (info, td_thr_tlsbase); -#undef TDB_VERBOSE_DLSYM -#undef TDB_DLSYM -#undef CHK - /* It's best to avoid td_ta_thr_iter if possible. That walks data structures in the inferior's address space that may be corrupted, or, if the target is running, may change while we walk them. If @@ -587,6 +582,15 @@ try_thread_db_load_1 (struct thread_db_info *info) currently on core targets, as it uses ptrace directly. */ if (target_has_execution && linux_proc_task_list_dir_exists (ptid_get_pid (inferior_ptid))) + info->td_ta_thr_iter_p = NULL; + else + CHK (TDB_VERBOSE_DLSYM (info, td_ta_thr_iter)); + +#undef TDB_VERBOSE_DLSYM +#undef TDB_DLSYM +#undef CHK + + if (info->td_ta_thr_iter_p == NULL) { struct lwp_info *lp; int pid = ptid_get_pid (inferior_ptid); @@ -1246,7 +1250,7 @@ find_new_threads_once (struct thread_db_info *info, int iteration, data.new_threads = 0; /* See comment in thread_db_update_thread_list. */ - gdb_assert (!target_has_execution); + gdb_assert (info->td_ta_thr_iter_p != NULL); TRY { -- 2.5.0