[PATCH] Fix a crash that occurs when PWD is invalid.

Filip Pizlo fpizlo at apple.com
Mon Dec 9 13:58:21 PST 2013


On Dec 9, 2013, at 12:42 PM, Andrew Trick <atrick at apple.com> wrote:

> 
> On Dec 9, 2013, at 12:01 PM, Eric Christopher <echristo at gmail.com> wrote:
> 
>> Out of curiosity why isn't it able to get a compilation dir?
> 
> Probably one of these.
> 
>     The getcwd() function will fail if:
> 
>     [EACCES]           Read or search permission was denied for a component of the pathname.
> 
>     [ENOENT]           A component of the pathname no longer exists.
> 
> Phil might know for sure.

I'm not sure, actually. ;-)  When I hit the bug it was probably ENOENT caused by weirdness in our JSC test harness.

But, broadly, there is no requirement for a client of JavaScriptCore to run with $PWD set to anything remotely sensible.  Moreover, it's my understanding that libraries and frameworks in general never assume anything about the sanity of $PWD unless they are asked to do relative path IO.  This isn't just a JSC bug: if the claim is that LLVM is a JIT library then it's probably best if LLVM gracefully handles not having a sane $PWD.

-Filip


> 
> -Andy
> 
>> 
>> -eric
>> 
>> On Mon, Dec 9, 2013 at 11:41 AM, Andrew Trick <atrick at apple.com> wrote:
>>> MCJIT needs to be able to run in hostile environments, even when PWD
>>> is invalid. There's no need to crash MCJIT in this case.
>>> 
>>> If we do want to guarantee valid CompilationDir, that should be done
>>> only for clients of getCompilationDir(). This is as simple as checking
>>> for an empty string.
>>> 
>>> The obvious fix is to simply leave MCContext's CompilationDir empty
>>> when PWD can't be determined. The only behavioral difference would be
>>> that EmitGenDwarfInfo would output an empty string when recording the
>>> working dir for the assembly output.
>>> 
>>> 
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131209/68b6728f/attachment.html>


More information about the llvm-commits mailing list