[v2] Fix asertion failure while analysing core files in AIX with terminated threads.
| Message ID | 20260324141545.32330-2-akamath996@gmail.com |
|---|---|
| State | New |
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 832894BA23FE for <patchwork@sourceware.org>; Tue, 24 Mar 2026 14:16:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 832894BA23FE 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=EqLWFJfk X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id CD0434BA2E0B for <gdb-patches@sourceware.org>; Tue, 24 Mar 2026 14:16:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD0434BA2E0B 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 CD0434BA2E0B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774361788; cv=none; b=L5w6iVd+qMZSwmsn+VZtHj7MZzd/SCJV2iCuOuF7El+oR++DSDbavYdoCH+JrSdmoPVUNUdldLBjtwjzHt+AyS12x2d5aIdxnldEW8K53XS5niWegYm9gcNj2gIe4MT0XqGNzwz9EKzIpae3PsO+VVJFrotTttLpn2/7QjgcFzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774361788; c=relaxed/simple; bh=ywRjqd0bgbBMr6u583W+NUg3lUmJKAFXS3RyJoBuJAs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=W/0FSUI3y6lTSVjDuyVeyCma1vKUQLDrQOYXZJ8tjjPFrdTPPygAaK+2MTdoFjXx0U+XaGzMYQgfrLNYCcQ8pCQx9PV543qWcnrAW5ZoxmOzJMTSfsz9hMbRqvgXgc6xcJvtbDKzi/J9YuvcJObtjKO4oDBO/UIz8mkAErpP7Ic= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD0434BA2E0B Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-82a62714fe6so2672058b3a.0 for <gdb-patches@sourceware.org>; Tue, 24 Mar 2026 07:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774361787; x=1774966587; 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=sK/ur+0C2THTbXzo2UK6WmbmnbXa0/MzALIjA0OW6io=; b=EqLWFJfkK09/ftcCkhZ5T+e5f5M81OnjnofdOLUuM0wYr/1MpM0EqWnS6R2MwFkr6c EP7ajRX0OCvBfITp1BjNgxGWXPBm6uUyRne8bFpp1E+oyVgDED06l37GtYce5wfZTnyL ppn+VYgwLFx/RnY3Awko+xkjU6+t2BbEAlKwPFSyi5st0KVZucXMdnUt+w1+5mlqyfnI RLkCaSX3FWiNqdqHdhr59XJvK1sbpuvmUI0ZFBA2skq8chsxza/+I/AeFPsO9xHz2Wi/ ebsvwaoaowl1Dz40bk5VPX5lPaq/ii/YAv4SVjKHX7sG79QSdT3BFpxJh1PZ9HLf4p+M J48A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774361787; x=1774966587; 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=sK/ur+0C2THTbXzo2UK6WmbmnbXa0/MzALIjA0OW6io=; b=UfvDc6VrtqifN49JFOleNEc3t5DEVKQ5ce+i/cVgiqowiTZs6xFX5RUKnAmO9UlEEk VLAJfYDMTCzj9EVGdLxCMNDRWOmk1ut00kBQ99TXlbHNKs/WmSC3EyyOkIJVV2sWBHvI /auSj2+FNithJeOLw1xukfuLg0qBpmSHOtBskO2xjBnoSbXYs3VNXphbyu5njcmTXrxs 7BD2oCzfvdvf0IIfDvfPQ8MWUAFapT2RO4FFzoL9pJV+tceNAm74IleFYPkvEhQyp6Oy e5mAez2N30Tg+Q5Ul2tR23GccwcXdde1w0EzYrdG3fAhexITCLxabVaysl8giXfM+m5m rhMA== X-Gm-Message-State: AOJu0YzpxgBEshl8QsckxMxBy/ykZV+1lQZnR9NPgqhy/vnjamaUerg6 GrPhPRCXOkq26jK47NVos04lbZixgULAlQnXSrtvNUKgvNjzXfO5PjrL X-Gm-Gg: ATEYQzy2O3RxNBNPwX8VqgQ8Eu51PHsfwy4zm/H2D0j46EXXQKMGverQ5WNzqL4L+jr Di/Gp/jzZBwcg3tORicV/19Oo8poixbuP1Dva28FZdVa4gUmhHREuJBm/fYBsBrLMhnKUP3WYWl YwOyks00zpKYyepUv13XGMNGJ2s/wToYpz53NdtBiJyLYGPY274Zs8LJ6/405SGk6JOZPxlIuip VhroyCNslD87ngkyRaieDFkzIUBLuSvGJsAWzEexhqTJOmmtQaZ+Yh05VjnZ+kDUsQcJECTUju2 JnzixWIKL9CjvOPjcMQ2ro8cZiiEjpksmfxm/XlbZ8Pptp8Gdv5C8pk+CTdKJbVvJeeqWWkYv0d eQvIVzWwmeyUMlZU/+FdZvxtPRQmMBlIbW2lnzjw6ds8bQhCR1+/me9o/D3UZr/q6493eLNSyMY swjnZftqu1CpthSwGyll3HlOAaVTFP7KyUZDi7mw3/cfpx7w== X-Received: by 2002:a05:6a00:a0d:b0:81f:544b:3998 with SMTP id d2e1a72fcca58-82c5be746f4mr2921391b3a.26.1774361786574; Tue, 24 Mar 2026 07:16:26 -0700 (PDT) Received: from localhost.localdomain ([122.171.16.28]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82b0410b1bdsm16105128b3a.57.2026.03.24.07.16.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 24 Mar 2026 07:16:26 -0700 (PDT) From: Aditya Vidyadhar Kamath <akamath996@gmail.com> 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 <aditya.kamath1@ibm.com> Subject: [PATCH v2] Fix asertion failure while analysing core files in AIX with terminated threads. Date: Tue, 24 Mar 2026 19:45:46 +0530 Message-ID: <20260324141545.32330-2-akamath996@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GB_FREEMAIL_NUM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
[v2] Fix asertion failure while analysing core files in AIX with terminated threads.
|
|
Checks
| Context | Check | Description |
|---|---|---|
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Build passed |
| linaro-tcwg-bot/tcwg_gdb_build--master-arm | success | Build passed |
| linaro-tcwg-bot/tcwg_gdb_check--master-arm | success | Test passed |
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 | success | Test passed |
Commit Message
Aditya Vidyadhar Kamath
March 24, 2026, 2:15 p.m. UTC
From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com>
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.
In AIX we see this in 7.3 from any python3 core file dumps.
The fix is to call sync_threadlists () only for a program in execution and
not for core files.
---
gdb/aix-thread.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
On 3/24/26 10:15 AM, Aditya Vidyadhar Kamath wrote: > From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com> > > 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. Looking at how it works on Linux, the threads are in state THREAD_STOPPED when looking at a core dump. I think that THREAD_STOPPED makes sense, because when looking at a core, you are looking at a snapshot of the process state when it was still alive, with all threads stopped. Could the AIX target do the same? I think it would be nice for consistency across targets. Simon
Simon Marchi <simon.marchi@polymtl.ca> wrote: >On 3/24/26 10:15 AM, Aditya Vidyadhar Kamath wrote: > >From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com> > > > >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. > >Looking at how it works on Linux, the threads are in state >THREAD_STOPPED when looking at a core dump. I think that >THREAD_STOPPED >makes sense, because when looking at a core, you are looking at a >snapshot of the process state when it was still alive, with all >threads stopped. Isn't this actually what happens with Aditya's latest patch? Given that sync_threadlists is no longer called, all threads should remain in the state common code set up for them initially, which I think would be THREAD_STOPPED? Bye, Ulrich
On 2026-03-25 07:56, Ulrich Weigand wrote: > Simon Marchi <simon.marchi@polymtl.ca> wrote: >> On 3/24/26 10:15 AM, Aditya Vidyadhar Kamath wrote: >>> From: Aditya Vidyadhar Kamath <aditya.kamath1@ibm.com> >>> >>> 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. >> >> Looking at how it works on Linux, the threads are in state >> THREAD_STOPPED when looking at a core dump. I think that >> THREAD_STOPPED >> makes sense, because when looking at a core, you are looking at a >> snapshot of the process state when it was still alive, with all >> threads stopped. > > Isn't this actually what happens with Aditya's latest patch? > Given that sync_threadlists is no longer called, all threads > should remain in the state common code set up for them initially, > which I think would be THREAD_STOPPED? > > Bye, > Ulrich Ah ok, I didn't catch that, but now that I re-read the commit message it indeed sounds like it, thanks. Simon
Aditya Vidyadhar Kamath <akamath996@gmail.com> wrote: >- sync_threadlists (pid); >+ /* Attempt to sync_threadlists () only when debugging object files >+ and not core files since list of threads never change for core >+ files. */ >+ if (target_has_execution ()) >+ sync_threadlists (pid); This is OK. Thanks, Ulrich
Hi Ulrich, Simon and community members, Thank you Ulrich and Simon for your feedback. >>+ if (target_has_execution ()) >>+ sync_threadlists (pid); >This is OK. Thanks. I have pushed the same. https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=edf0ae3b9f1ca23daaa55628683edc9a3360286f
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index c2e6b6d2bd6..5469ddca4f7 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -884,7 +884,11 @@ pd_update (pid_t pid) if (status != PTHDB_SUCCESS) return ptid_t (pid); - sync_threadlists (pid); + /* Attempt to sync_threadlists () only when debugging object files + and not core files since list of threads never change for core + files. */ + if (target_has_execution ()) + sync_threadlists (pid); /* Define "current thread" as one that just received a trap signal. */