Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Nov 2014 10:33:47 +0000
From:      Mike Gelfand <Mike.Gelfand@LogicNow.com>
To:        "hackers@freebsd.org" <hackers@freebsd.org>
Subject:   [BUG] Getting path to program binary sometimes fails
Message-ID:  <91809230-5E81-4A6E-BFD6-BE8815A06BB2@logicnow.com>

next in thread | raw e-mail | index | archive | help
Hello,

I=92ve been advised (on #freebsd @FreeNode) to send a mail here with detail=
s.

I=92m observing a weird issue where process may not able to determine path =
to its own binary (and maybe other process binaries as well, thought I didn=
=92t test that) under some [not yet clear to me] conditions. The code I use=
 in production first tries to call sysctl(KERN_PROC_PATHNAME) and if that f=
ails fallback to call readlink(/proc/curproc/file); at some point both call=
s fail with ENOENT. This happens on two FreeBSD 9 (vanilla 9.1-RELEASE and =
9.2-RELEASE) machines, and never happens (or at least never happened in ove=
r two years) on FreeBSD 8 (vanilla 8.3-RELEASE-p3); all machines are amd64.=
 I=92ve been able to reduce the test case to a sample program [1] which I r=
un using a sample script [2], and the error then happens when I=92m buildin=
g clang-devel from ports. I=92ve also recorded a screencast [3].

Is this a know defect? Do you need any other information other than provide=
d above to reproduce?

[1] http://mikedld.com/f/selfpath/selfpath.c
[2] http://mikedld.com/f/selfpath/selfpath.sh
[3] http://mikedld.com/f/selfpath/selfpath.mov

Kind regards,
Mike




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?91809230-5E81-4A6E-BFD6-BE8815A06BB2>