From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3161E3858D38; Mon, 25 Mar 2024 13:48:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3161E3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711374522; bh=Nhmbf7cDRRf4akl6SKVdTaeCSvnOCRt7UbriFzxf8Dc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WACCEqkPurGtJG8qtgXMXGKJ3ObHca0RZsCFluEpkW+0SJjq5nx7YS6SQ+seTSJrS HNln4OnaMXWnZKdqKAYzdqVpK7cL4CvfXrZ832whF0oEnosl7NJEG+jgu7J1ziVDxS 5AktKSddcJecymlIc2+EtZJpaoTe8xq5+PeLMURo= From: "vries at gcc dot gnu.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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31528 --- Comment #4 from Tom de Vries --- (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=3D1216352=20 > > - https://bugzilla.kernel.org/show_bug.cgi?id=3D211593 > > so maybe this needs fixing first. >=20 > 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 =3D readlink (name, buf, PATH_MAX - 1); > - if (len <=3D 0) > - strcpy (buf, name); > - else > - buf[len] =3D '\0'; > - > - /* Use /proc/PID/exe if the actual file can't be read, but /proc/PID/e= xe > - can be. */ > - if (access (buf, R_OK) !=3D 0 && access (name, R_OK) =3D=3D 0) > - strcpy (buf, name); > + xsnprintf (buf, PATH_MAX, "/proc/%d/exe", pid); >=20=20 > return buf; > } > ... This turned out to be more complicated that I thought, so I've recorded thi= s as a fixme in the submitted patch. --=20 You are receiving this mail because: You are on the CC list for the bug.=