From: Matthieu Longo <matthieu.longo@arm.com>
To: Simon Marchi <simark@simark.ca>
Cc: Thiago Jung Bauermann <thiago.bauermann@linaro.org>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2] gdb: rely on the first non-exited thread TPID when reading Linux procfs files
Date: Thu, 17 Sep 2026 11:37:24 +0100 [thread overview]
Message-ID: <2fafae56-0084-4c91-8eea-18cb760d0375@arm.com> (raw)
In-Reply-To: <ce6e6d9d-f253-437f-908e-519f0157ebeb@arm.com>
On 03/09/2026 23:56, Matthieu Longo wrote:
> On 24/08/2026 17:21, Matthieu Longo wrote:
>> On Linux, /proc/<pid> is keyed by the thread-group leader PID. When
>> the leader has exited, some /proc/<pid>/... entries become unavailable
>> even though another thread is still alive. This can happen, for instance,
>> when the main thread calls pthread_exit() and another thread continues
>> the execution (existing test: gcore-stale-thread).
>>
>> This causes GDB to fail to read procfs entries such as cmdline, cwd,
>> exe, maps, and smaps when it uses 'current_inferior ()->pid' after the
>> thread-group leader has exited.
>>
>> Fix this by adding inferior::first_non_exited_thread(), which returns
>> the PTID of the first non-exited thread of the inferior. Use its LWP ID
>> when accessing procfs entries that only need a representative live LWP
>> belonging to the process.
>>
>> This is a best-effort choice of a thread that is expected to still exist
>> in the target. Since GDB's view of the threads list may be stale, the
>> selected thread may already have exited by the time it is accessed.
>> Callers must therefore still be prepared to handle that case.
>>
>> Update the following functions:
>> - linux_info_proc
>> - linux_process_address_in_memtag_page
>> - linux_find_memory_regions_full
>> - linux_fill_prpsinfo
>> - linux_address_in_shadow_stack_mem_range
>> to use the first non-exited thread's LWP ID instead of the inferior PID
>> when constructing procfs paths.
>>
>> Add a new test in gdb.threads.
>>
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31207
>>
>> Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
> Ping
Ping
next prev parent reply other threads:[~2026-09-17 10:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 16:21 Matthieu Longo
2026-09-03 22:56 ` Matthieu Longo
2026-09-17 10:37 ` Matthieu Longo [this message]
2026-09-17 15:43 ` Simon Marchi
2026-09-17 20:18 ` Simon Marchi
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=2fafae56-0084-4c91-8eea-18cb760d0375@arm.com \
--to=matthieu.longo@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
--cc=thiago.bauermann@linaro.org \
/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