public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/31528] [gdb, kernel.yama.ptrace_scope=1] FAIL: gdb.base/attach-deleted-exec.exp: attach to process with deleted executable
Date: Mon, 25 Mar 2024 13:48:41 +0000 [thread overview]
Message-ID: <bug-31528-4717-pmFn3dZwk3@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31528-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=31528
--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #2)
> (In reply to Tom de Vries from comment #1)
> > Regardless, it seems that using readlink in linux_proc_pid_to_exec_file may
> > be a problem in itself, see:
> > - https://bugzilla.suse.com/show_bug.cgi?id=1216352
> > - https://bugzilla.kernel.org/show_bug.cgi?id=211593
> > so maybe this needs fixing first.
>
> Which would be fixed by:
> ...
> diff --git a/gdb/nat/linux-procfs.c b/gdb/nat/linux-procfs.c
> index b17e3120792..2f8a3b961f7 100644
> --- a/gdb/nat/linux-procfs.c
> +++ b/gdb/nat/linux-procfs.c
> @@ -342,20 +342,7 @@ const char *
> linux_proc_pid_to_exec_file (int pid)
> {
> static char buf[PATH_MAX];
> - char name[PATH_MAX];
> - ssize_t len;
> -
> - xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
> - len = readlink (name, buf, PATH_MAX - 1);
> - if (len <= 0)
> - strcpy (buf, name);
> - else
> - buf[len] = '\0';
> -
> - /* Use /proc/PID/exe if the actual file can't be read, but /proc/PID/exe
> - can be. */
> - if (access (buf, R_OK) != 0 && access (name, R_OK) == 0)
> - strcpy (buf, name);
> + xsnprintf (buf, PATH_MAX, "/proc/%d/exe", pid);
>
> return buf;
> }
> ...
This turned out to be more complicated that I thought, so I've recorded this as
a fixme in the submitted patch.
--
You are receiving this mail because:
You are on the CC list for the bug.
prev parent reply other threads:[~2024-03-25 13:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-22 10:15 [Bug gdb/31528] New: " vries at gcc dot gnu.org
2024-03-22 14:15 ` [Bug gdb/31528] " vries at gcc dot gnu.org
2024-03-22 14:21 ` vries at gcc dot gnu.org
2024-03-22 14:26 ` vries at gcc dot gnu.org
2024-03-25 13:47 ` vries at gcc dot gnu.org
2024-03-25 13:48 ` vries at gcc dot gnu.org [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=bug-31528-4717-pmFn3dZwk3@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=gdb-prs@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).