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 1/2] Fix asertion failure while analysing core files in AIX with terminated threads.
Date: Tue, 24 Mar 2026 15:22:14 +0530 [thread overview]
Message-ID: <20260324095213.46219-2-akamath996@gmail.com> (raw)
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.
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
next reply other threads:[~2026-03-24 9:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 9:52 Aditya Vidyadhar Kamath [this message]
2026-03-24 12:00 ` Ulrich Weigand
2026-03-24 12:43 ` Aditya Kamath
2026-03-24 13:42 ` Ulrich Weigand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260324095213.46219-2-akamath996@gmail.com \
--to=akamath996@gmail.com \
--cc=Aditya.Kamath1@ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=sangamesh.swamy@in.ibm.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
--cc=ulrich.weigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox