[Lldb-commits] [lldb] [lldb] Use correct path for lldb-server executable (PR #131519)
Yuval Deutscher via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 20 01:25:37 PDT 2025
yuvald-sweet-security wrote:
> > Ah, turns out there's a HostInfo::GetProgramFileSpec() function which solves both these issues.
>
> I am aware of that function. The reason I did not suggest it is because `GetProgramFileSpec` (on linux) returns the canonical path (with all symlinks resolved). That's something I am generally trying to avoid because it can break some instalation types -- where the installation consists of a symlink farm and the expected installation layout is given by the symlink tree. (It can also fix some installations which expect exactly the opposite -- the debian use case in one of them).
I understand, but I think that for lldb-server this isn't much of an issue as it seems relatively stand-alone. I'd be more worried if this code attempted to execute a binary that isn't `lldb-server` from the LLVM binary directory; however, since this code is strictly used for lldb-server to re-execute itself with different arguments, I don't think relying on `GetProgramFileSpec` is an issue - and it is definitely better than using argv[0], which might as well be the canonical path, depending on how the user executed it.
> Whatever we do, I think it is better to resolve the symlink as late as possible as that gives us more options down the line. What I don't understand is why doesn't this work for your use case already -- `GetModuleFileSpecForHostAddress` calls `FileSystem::Resolve`, which should give you the canonical path for the library. Does that fail for some reason? It is it because the (relative) path returned by `GetModuleFileSpecForHostAddress` is resolved relative to CWD (but in reality we've executed it by finding the executable on the path)?
I'm assuming this is referring to the other issue, which I discuss in https://github.com/llvm/llvm-project/pull/131609? Because the issue in the current PR is not related to `GetModuleFileSpecForHostAddress` - `argv[0]` is piped directly into `spawn_process` without any canonicalization of paths.
https://github.com/llvm/llvm-project/pull/131519
More information about the lldb-commits
mailing list