[PATCH] D147652: [symbolizer] Check existence of input file in GNU mode

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 09:01:03 PDT 2023


sepavloff added a comment.

In D147652#4267604 <https://reviews.llvm.org/D147652#4267604>, @jhenderson wrote:

> In D147652#4267555 <https://reviews.llvm.org/D147652#4267555>, @sepavloff wrote:
>
>> When llvm-symbolizer check existence of binary file, it creates its representation in memory. Even if the file then disappears or is changed, that does not affect decoding process, with uses the cached representation.
>
> I was thinking the early check could just be a "file exists" check, and not to try to open it until later when it's actually used. That would fit better into how the code currently works.

It would not solve the problem in full. A file can exists but be inaccessible for user or have incorrect format. GNU `addr2line` in this case exits with error but `llvm-addr2line` waits for input addresses. It is safer to exit early because no useful job can be done if input file is wrong. To implement the safer solution, the check for existence should be made prior to the loop that waits input from stdin.

This complexity is caused by the fact that in native mode `llvm-symbolizer` can read binary file name from input stream. In this mode wrong input file is not a reason to stop working - the next data in stdin can query about different file. This is why `llvm-symbolizer` opens input file late, after it reads input stream.

To support both modes of `llvm-symbolizer` the existence check should be made in two places, prior to reading standard input and in the reading loop, depending on the used mode.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147652/new/

https://reviews.llvm.org/D147652



More information about the llvm-commits mailing list