Re: [PATCH v1 5/6] gdb/linux-tdep: migrate linux_find_memory_regions_full to file_reader_t

Thiago Jung Bauermann <[email protected]> Mon, 03 Aug 2026 05:01:21 +0000
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Matthieu Longo <[email protected]> writes:

> The previous implementation of linux_find_memory_regions_full could
> still return success even when none of the /proc/PID/[s]maps files
> existed, or all reads returned 0 bytes (this last case can happen on
> Linux when the thread-group leader has exited).
> As a result, the function could incorrectly succeed, allowing core
> dump generation via the gcore command.
> This logical defect was allowing, by chance, the function to return
> success and hence, allowing fortuitously the coredump generation via
> gcore command (see gcore-stale-thread test for more details).
>
> A previous patch in this patch series fixed this issue by using the
> first LWP ID of the current inferior instead of relying on the PID.
> This patch adapts the code to use file_reader_t and makes the function
> return an error if reading any of the procfs files fails.
> ---
>  gdb/linux-tdep.c | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)

Reviewed-by: Thiago Jung Bauermann <[email protected]>

-- 
Thiago
(he/him)