Date: Tue, 7 May 2013 14:08:06 -0700 From: Garrett Cooper <yaneurabeya@gmail.com> To: dim@freebsd.org Cc: toolchain@freebsd.org Subject: Re: clang doesn't make temporary files in all instances, causes build races by not using mk*temp(3) in /tmp Message-ID: <CAGHfRMDdB0TSsigizCU-hn9gAdJcq5_o6MeDeckGd3zmjYbmTg@mail.gmail.com> In-Reply-To: <CAGHfRMCnmViGvJadmmmKyE=mAdgWFbX5woPUbGb3mdUVkUbFeQ@mail.gmail.com> References: <CAGHfRMCnmViGvJadmmmKyE=mAdgWFbX5woPUbGb3mdUVkUbFeQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, May 7, 2013 at 1:58 PM, Garrett Cooper <yaneurabeya@gmail.com> wrote: > Hi Dimitriy, > I ran into the following error when trying to execute make > tinderbox with FreeBSD svn head with ATF changes I'm going to push to > benno@: > > cc -O -pipe -DHAVE_CONFIG_H > -I/scratch/freebsd/head-svn/gnu/lib/libgomp -I. > -I/scratch/freebsd/head-svn/gnu/lib/libgomp/../../../contrib/gcclibs/libgomp > -I/scratch/freebsd/head-svn/gnu/lib/libgomp/../../../contrib/gcclibs/libgomp/config/posix > -std=gnu99 -Qunused-arguments -c > /scratch/freebsd/head-svn/gnu/lib/libgomp/../../../contrib/gcclibs/libgomp/config/posix/bar.c > -o bar.o > cc: error: unable to make temporary file: /tmp/bar: can't make unique > filename: Permission denied > *** [bar.o] Error code 1 > > Did some poking around in the clang source and it looks like it's > doing some less than intelligent things when generating "temporary" > paths (from contrib/llvm/tools/clang/lib/Driver/Driver.cpp ): > > 1598 std::string Driver::GetTemporaryPath(StringRef Prefix, const char *Suffix) > 1599 const { > 1600 // FIXME: This is lame; sys::Path should provide this function > (in particular, > 1601 // it should know how to find the temporary files dir). > 1602 std::string Error; > 1603 const char *TmpDir = ::getenv("TMPDIR"); > 1604 if (!TmpDir) > 1605 TmpDir = ::getenv("TEMP"); > 1606 if (!TmpDir) > 1607 TmpDir = ::getenv("TMP"); > 1608 if (!TmpDir) > 1609 TmpDir = "/tmp"; > 1610 llvm::sys::Path P(TmpDir); > 1611 P.appendComponent(Prefix); > 1612 if (P.makeUnique(false, &Error)) { > 1613 Diag(clang::diag::err_unable_to_make_temp) << Error; > 1614 return ""; > 1615 } > 1616 > 1617 // FIXME: Grumble, makeUnique sometimes leaves the file around!? PR3837. > 1618 P.eraseFromDisk(false, 0); > 1619 > 1620 if (Suffix) > 1621 P.appendSuffix(Suffix); > 1622 return P.str(); > > This logic (line 1612) is racy and incorrect. > This _needs_ to be fixed in clang to properly prefix and rename to > the target path in the filesystem where the compilation is being done > in order to avoid races with partial compilations, etc. And I was pointed to these awesome bug reports by someone internal to Isilon (thanks Anton!): - http://lists.cs.uiuc.edu/pipermail/llvmbugs/2012-August/024524.html - http://trac.macports.org/ticket/37834 It looks like the clang folks haven't fixed this issue yet. Arg.. Thanks, -Garrett
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGHfRMDdB0TSsigizCU-hn9gAdJcq5_o6MeDeckGd3zmjYbmTg>