[PATCH] D138658: [DebugInfo] Protect DIFile::Source against empty string

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 11:09:31 PST 2022


dblaikie added a comment.

In D138658#3951901 <https://reviews.llvm.org/D138658#3951901>, @Hahnfeld wrote:

> In D138658#3951900 <https://reviews.llvm.org/D138658#3951900>, @dblaikie wrote:
>
>> In D138658#3951887 <https://reviews.llvm.org/D138658#3951887>, @Hahnfeld wrote:
>>
>>> In D138658#3951866 <https://reviews.llvm.org/D138658#3951866>, @dblaikie wrote:
>>>
>>>> Where did this issue come up in practice? Change seems reasonable, but wouldn't mind having more context.
>>>
>>> Please see https://reviews.llvm.org/D137152 for context. I think what's happening is that we (the Cling interpreter in ROOT) create an empty source file while injecting some code during startup. It may be possible to fix that, but LLVM shouldn't crash from it.
>>
>> hmm, more context might be nice - like where's the Cling code that's doing something different than the Clang code when it's creating DIFiles?
>
> I think it's actually Clang code that just passes on the result of `getSource`: https://github.com/llvm/llvm-project/blob/fb2f3b30b2ab2494aedf54940f80258e073f0486/clang/lib/CodeGen/CGDebugInfo.cpp#L426 which is not protected against empty strings: https://github.com/llvm/llvm-project/blob/fb2f3b30b2ab2494aedf54940f80258e073f0486/clang/lib/CodeGen/CGDebugInfo.cpp#L376-L388

That seems a Cling-novelty though, right? A zero-length file isn't valid in C++ (you have to have a newline at the end) and I guess if you give clang a truly zero-length file it doesn't generate DWARF at least, or doesn't do any code generation at all? So maybe Cling should do something similar to whatever clang does with a zero-length file? (or does clang hit the same problem if you give it a zero-length file?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138658



More information about the llvm-commits mailing list