[LLVMdev] [llvm-commits] Dealing with a corrupted /proc/self/exe link (original) (raw)

Benjamin Kramer benny.kra at gmail.com
Fri Jul 13 12:17:52 PDT 2012


On 13.07.2012, at 09:46, Gabor Greif <gabor.greif at alcatel-lucent.com> wrote:

Hi all,

I am in charge of the controlled introduction of clang into our builds at my workplace. Since all our tools must run from a ClearCase view for automatic dependency tracking, we have been biten by a Linux bug, and readlink("/proc/self/exe", ...) gives nonsensical results. So we need to introduce a configure option for disallowing this method of executable discovery (the other one works well).

Interesting, can you describe the linux bug? Are the kernel devs aware of it?

We often had reports about /proc/self/exe not working (and thus clang crashing) in chrooted environments. It is possible to mount /proc into the chroot but this seems to be missing from many setups. The code in LLVM that uses /proc/self/exe returns an empty string on error which confuses clang.

I don't really like having an autoconf switch for this as long as you can determine whether the result from /proc/self/exe is valid. When you're adding a fallback to Path.inc anyways, why not just try reading /proc/self/exe first, and if it fails, use your fallback? That would also fix the chroot problem.

Here is the patch:

Index: autoconf/configure.ac =================================================================== --- autoconf/configure.ac (revision 160127) +++ autoconf/configure.ac (working copy) @@ -647,6 +647,20 @@ ACDEFINEUNQUOTED([ENABLETIMESTAMPS],$ENABLETIMESTAMPS, [Define if timestamp information (e.g., DATE) is allowed]) +dnl Enable reading of the "/proc/self/exe" link. +ACARGENABLE(proc-self-exe, + ASHELPSTRING([--enable-proc-self-exe], + [Enable reading of the "/proc/self/exe" link (default is YES)]),, + enableval=default) +case "$enableval" in + yes) ACSUBST(ENABLEPROCSELFEXE,[1]) ;; + no) ACSUBST(ENABLEPROCSELFEXE,[0]) ;; + default) ACSUBST(ENABLEPROCSELFEXE,[1]) ;; + *) ACMSGERROR([Invalid setting for --enable-proc-self-exe. Use "yes" or "no"]) ;; +esac +ACDEFINEUNQUOTED([ENABLEPROCSELFEXE],$ENABLEPROCSELFEXE, + [Define if reading of the "/proc/self/exe" link is allowed]) + dnl Allow specific targets to be specified for building (or not) TARGETSTOBUILD="" ACARGENABLE([targets],ASHELPSTRING([--enable-targets], I'll commit after a LGTM. However before tweaking lib/Support/Unix/Path.inc I have to add a cmake modification, which can be simply . Hints how to do this are welcome, but I guess I'll figure it out. So what do you think? Cheers, Gabor


llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-dev mailing list