Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matthieu Longo <matthieu.longo@arm.com>
To: gdb-patches@sourceware.org, Simon Marchi <simark@simark.ca>
Cc: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Subject: Re: [PATCH v2] gdb: rely on the first non-exited thread TPID when reading Linux procfs files
Date: Thu, 3 Sep 2026 23:56:27 +0100	[thread overview]
Message-ID: <ce6e6d9d-f253-437f-908e-519f0157ebeb@arm.com> (raw)
In-Reply-To: <20260824162155.467233-1-matthieu.longo@arm.com>

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

      reply	other threads:[~2026-09-03 22:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 16:21 Matthieu Longo
2026-09-03 22:56 ` Matthieu Longo [this message]

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=ce6e6d9d-f253-437f-908e-519f0157ebeb@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