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

Andrew Trick atrick at apple.com
Mon Dec 9 21:01:52 PST 2013


On Dec 9, 2013, at 8:38 PM, Eric Christopher <echristo at gmail.com> wrote:

>> We’re not running into this case, nor do I think it is possible. However, I
>> did hack an LLVM build to test this code path, and I think this is the patch
>> you’re looking for:
>> 
> 
> I don't know what you mean by "not running into this case, nor do I
> think it is possible" the statement doesn't make a lot of sense. You'd
> basically have to pass the compilation dir in - right now if you want
> to set it via clang's -fcompilation-dir= option it just modifies the
> metadata. To do it in the backend you'd probably want a command line
> option in MCContext.cpp.
> 
> I'm also quite concerned how you're running into this and that you're
> not papering over a bug from somewhere else.
> 
> That said, this patch is obviously not too much of a hack around
> functionality and should be fine. I'd have preferred the command line
> option because then you could provide a way to test this workaround.

Thanks. I think this thread is done. I’ll make one more attempt to be less confusing...

The case I am fixing:

Some (non-clang) client
- links LLVM
- initializes MCContext
- causes getcwd to return an error

This case used to crash. Now it doesn't crash.

The case Eric is concerned about:

Some unlikely client
- Compiles a .s file as source
- Generates debug info for that .s
- Targets a .o file (filetype=obj)
- causes getcwd to return an error

This case used to definitely crash. It almost certainly still crashes. But now,
if by some miracle it doesn't crash we will skip the AT_comp_dir attribute instead
of emitting an empty AT_comp_dir.

-Andy



More information about the llvm-commits mailing list