[BUG] Getting path to program binary sometimes fails

Mike Gelfand Mike.Gelfand at LogicNow.com
Thu Nov 13 10:49:01 UTC 2014


Hello,

I’ve been advised (on #freebsd @FreeNode) to send a mail here with details.

I’m 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’t 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 fails fallback to call readlink(/proc/curproc/file); at some point both calls 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 over two years) on FreeBSD 8 (vanilla 8.3-RELEASE-p3); all machines are amd64. I’ve been able to reduce the test case to a sample program [1] which I run using a sample script [2], and the error then happens when I’m building clang-devel from ports. I’ve also recorded a screencast [3].

Is this a know defect? Do you need any other information other than provided 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



More information about the freebsd-hackers mailing list