From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kfEoLRtfwmnV5DYAWB0awg (envelope-from ) for ; Tue, 24 Mar 2026 05:53:31 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=LerEGOkg; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B3C621E04F; Tue, 24 Mar 2026 05:53:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 40C661E04F for ; Tue, 24 Mar 2026 05:53:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E25A94BAD16F for ; Tue, 24 Mar 2026 09:53:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E25A94BAD16F Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=LerEGOkg Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id EAD454BA23C8 for ; Tue, 24 Mar 2026 09:53:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EAD454BA23C8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EAD454BA23C8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774345984; cv=none; b=Lf7Tg1I+4GMEC38U2vYuhZOzq98Vshj93rAI8noQo1G7VaqRIEUhwbon/joZfYRVUDNUM9qrkSSqj3XvN4VPMO6T7UNpVusoU9rhdbI/cpLwK8GToIYuMni/0X+HNKZmdv54gkowsXJkWIuyJosyUN0i+Vv65kkDI8REas9MYpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774345984; c=relaxed/simple; bh=dTwvVWx4oMJyJ+7WvMn1yVOTkNjYjhxeXLGTLZq4JNc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Jy9CzS0rBUeDa7UIQKpfEXtFRtAjHvm5DBBAYyBT5hHaebnvCliqAjxgtBxcTWX9aCUlxdii6+J81s7rxjI6YGheFNswIMu+v+MrlHmu0UfjRdgvjmvEyo2EUUnJl36YamUxwtnIhKPOanqtmIzSqHFIe9zoqA/fQ6cVGARbcYA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAD454BA23C8 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-c73e9e4cdf7so1477213a12.2 for ; Tue, 24 Mar 2026 02:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774345983; x=1774950783; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MuQLEpfuiQtKsX+MLFSBJNo8Ji7BcVNT98h+vKGYHYU=; b=LerEGOkgL4M/WzXrLBEvp4fYnOhU4pbYHZ3wQFOnvKBoRxtQtjFZAucyk1Zr6r6pBD XbJXeWPqfI4R4J4sdAQZudlTJvyE08MWr+DQgBzz3sTzaz0Qp/4LECroFz7BLZOD93ou Jfm3cLj7V9v1Z+K69Yfo2/9ulofJRbLvhPZ1hM3mivTVaRWgk4So8Vm+RlrGPhKzcIpa 9Vlo+HxWbRLuLg3ARjMG4zUPhD3IZ7rbTrcqKdOQIvmzb4C+PFI4uQz/ELrTQAoyMtZk 5xxSqC2VAGn87ka2qPd5+Mdu4BELkhq5Irpmv4u0DHulWxMi+lEz2BM6C39j7OmMRhDe wujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774345983; x=1774950783; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MuQLEpfuiQtKsX+MLFSBJNo8Ji7BcVNT98h+vKGYHYU=; b=UJD+vmY0M2/DtpuFOMcuYe+dhg0GfPh1jnROgcDEzD9l6oXIUrm1IqwlnwjeaCW8Qq XAEzh9zoqlGUpwXt483M+d6MEnZAwWlYhJQQZlWzhUsAGzPIA32i8pNbOnH8LnWMM2wX WIC/1sSym73r8ssMqEAN7qPNhb7kQNBx32L018xTBKC6ihK7+ynnPJUJi4m5Pql5sJFx ow/aQzY0WxQwxFm89R9M+DE8AJKuTOCbZpNqj14Q8Nrs5kM/UQ7YlbFguEeYYFTlrWIs 5QQa9iJbz9H8ComCfgrHAuVRWoh7cwB6yM/OEpuzgY0RWGG5OwQjaOW+Y5PevBO0XGEg vd9g== X-Gm-Message-State: AOJu0YzdQ0piaC1iSZeX57ZZiYAH566awCEXoZngpcJ4YoI9TZuzv7n8 0jGRLL+SyP+cGWm8a4OVplXya4ZGQVpIxXc1btmHksfOfEfXeVxLyIUe X-Gm-Gg: ATEYQzxaUWoKgVYiuv7Hs7ASXGEJ5u9Y4qH5eLOyyT8O6f+apl/qulerK8D/e1Mehxm t88wCo8C9Vsp1iWiRUnFsdZ2+KC7ZWMZo80AXnwEoYTADXrm+bihftMu/iZUlDwaCnCcntJBSac g2mNTsfKtwr5ffV6b/UDUF6kQwpRCZKRmxVWQwqTLbBbSu1hLz9HVJkupAZ5o6xRrO6XehhzTXO QhYUv5J0RDheVQFqVBNeyy1BvIixeGDnpqkXCKxPqebdaDbGj0dBk9e5niPXlACA6M5KWnTzume FgC/Rs2dYssUxnH2Zd4qxVEv0MQZGD1bnfysfXLAXQW/bhamcQKob+B/ar1mwCdsTunL05hVjF0 ump+CH9BNkcxuq2Aq4TAzdlYpsn9+YLez4A3k2gsZzbQGqMyZGsfU2rfmLWjDAhkaz5LqElSzdQ dkXBpO8Xon0IGZ1c9E5zIYD2shtPf/4djJrR6Pu3kljIP7nw== X-Received: by 2002:a17:902:dad1:b0:2ae:cb0e:fd5e with SMTP id d9443c01a7336-2b08275878cmr159618455ad.23.1774345982855; Tue, 24 Mar 2026 02:53:02 -0700 (PDT) Received: from localhost.localdomain ([122.171.16.28]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b08365535bsm134696475ad.50.2026.03.24.02.52.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 24 Mar 2026 02:53:02 -0700 (PDT) From: Aditya Vidyadhar Kamath To: ulrich.weigand@de.ibm.com, simon.marchi@polymtl.ca, tom@tromey.com Cc: gdb-patches@sourceware.org, Aditya.Kamath1@ibm.com, sangamesh.swamy@in.ibm.com, Aditya Vidyadhar Kamath Subject: [PATCH 1/2] Fix asertion failure while analysing core files in AIX with terminated threads. Date: Tue, 24 Mar 2026 15:22:14 +0530 Message-ID: <20260324095213.46219-2-akamath996@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Aditya Vidyadhar Kamath If we analyse core files today in AIX ( few of them ) we get, regcache.c:432: internal-error: get_thread_regcache: Assertion `thread->state != THREAD_EXITED' failed. The reason being the aix-thread.c file where root cause is the sync_threadlists() function. When reading an AIX core file, threads are reported by libpthread library as being in PST_TERM (terminated) state, which is correct since process crashed. However, sync_threadlists() was calling delete_thread() for these terminated threads, marking them as THREAD_EXITED in GDBs internal state. Later, when GDB tried to fetchregisters or access frame information for these threads during core file analysis, it would hit an assertion in get_thread_regcache() that prevents accessing exited threads. The fix is to only delte threads which are terminated when we have execution i.e. debugging a binary. For a core file, we need to keep all threads, even terminated ones, so they can be analysed. In AIX we see this in 7.3 from any python3.12 core file dumps. This patch fixes the same. --- gdb/aix-thread.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index c2e6b6d2bd6..e891f510e08 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -830,8 +830,10 @@ sync_threadlists (pid_t pid) private_thread_info_up (priv)); } - /* The thread is terminated. Remove it. */ - if (state == PST_TERM) + /* If the thread is terminated remove it, but only if it is a binary + and has execution. If it is a core file, keep terminated threads + so we can analyse them. */ + if (target_has_execution () && state == PST_TERM) { thread_info *thr = proc_target->find_thread (ptid); gdb_assert (thr != nullptr); @@ -847,16 +849,20 @@ sync_threadlists (pid_t pid) where in the end after the threadfunc breakpoint is hit, the thread exits and gets into a PST_UNKNOWN state. So this thread will not run in the above for loop. Therefore the below for loop - is to manually delete such threads. */ - for (thread_info &it : all_threads_safe ()) + will manually delete such threads. We only do the for binaries in + execution. For core files keep all threads for analysis. */ + if (target_has_execution ()) { - aix_thread_info *priv = get_aix_thread_info (&it); - if (in_queue_threads.count (priv->pdtid) == 0 - && in_thread_list (proc_target, it.ptid) - && pid == it.ptid.pid ()) + for (thread_info &it : all_threads_safe ()) { - delete_thread (&it); - data->exited_threads.insert (priv->pdtid); + aix_thread_info *priv = get_aix_thread_info (&it); + if (in_queue_threads.count (priv->pdtid) == 0 + && in_thread_list (proc_target, it.ptid) + && pid == it.ptid.pid ()) + { + delete_thread (&it); + data->exited_threads.insert (priv->pdtid); + } } } } -- 2.41.0