Description
SIGSEGV happens when using llvm::logicalview
interfaces from a program built in Debug mode when LLVM was built in Release mode (or viceversa).
Description of the issue
The underlying cause is that the LVObject::ID
data member (see https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h#L173) is only part of the class definition if !NDEBUG
(i.e. in Debug builds).
Given that NDEBUG
has a different definition during LLVM builld (matching LLVM's build mode), and a different one when the LVObject.h
header is parsed in the downstream project (that consumes the debuginfologicalview
library), this class definition may violate the ODR (due to different class layouts), resulting in visible crashes.
Reproducer
Not attaching a particular call stack (!important) / reproducer, as the problem could be potentially reproduced in any context that matches the explanation above.
Ideas for a fix
The following are just a couple of ideas for fixing this situation:
- Either we make
ID
an unconditional data member of theLVObject
class - Or... we extend
llvm-config.h.cmake
to incorporate aLLVM_BUILD_DEBUG
PP macro that we could use in this case (and possibly other cases throughout LLVM) - Or... we completely remove
ID
(andstatic GID
), if it is not a useful debugging feature anymore
FYI, @CarlosAlbertoEnciso. I can take care of this in a PR, but first let's agree on any of the solutions above (or any other that we could come up with).
Activity
llvmbot commentedon May 12, 2025
@llvm/issue-subscribers-debuginfo
Author: Javier Lopez-Gomez (jalopezg-git)
Description of the issue
The underlying cause is that the
LVObject::ID
data member (see https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/DebugInfo/LogicalView/Core/LVObject.h#L173) is only part of the class definition if!NDEBUG
(i.e. in Debug builds).Given that
NDEBUG
has a different definition during LLVM builld (matching LLVM's build mode), and a different one when theLVObject.h
header is parsed in the downstream project (that consumes thedebuginfologicalview
library), this class definition may violate the ODR (due to different class layouts), resulting in visible crashes.Reproducer
Not attaching a particular call stack (!important) / reproducer, as the problem could be potentially reproduced in any context that matches the explanation above.
Ideas for a fix
The following are just a couple of ideas for fixing this situation:
ID
an unconditional data member of theLVObject
classllvm-config.h.cmake
to incorporate aLLVM_BUILD_DEBUG
PP macro that we could use in this case (and possibly other cases throughout LLVM)ID
(andstatic GID
), if it is not a useful debugging feature anymoreFYI, @CarlosAlbertoEnciso. I can take care of this in a PR, but first let's agree on any of the solutions above (or any other that we could come up with).
CarlosAlbertoEnciso commentedon May 12, 2025
There is an option
--attribute=id
(Prints unique element ID), which includes theID
for the logical element and it is used to debug issues as you can put a breakpoint for that specific value. If the debug information does not change, that ID is the same, which is quite useful, during development.Removing that functionality I don't think it is a good option.
CarlosAlbertoEnciso commentedon May 12, 2025
Making
ID
an unconditional data member of theLVObject
class, it will solve the issue, but it will increase the size, which I don't think is a desirable option, asID
is used only for debugging.There is a PR #69160 that mention the size issue.
CarlosAlbertoEnciso commentedon May 12, 2025
Or... we extend llvm-config.h.cmake to incorporate a LLVM_BUILD_DEBUG PP macro that we could use in this case (and possibly other cases throughout LLVM)
I guess this is the only option left.
jalopezg-git commentedon May 12, 2025
Agreed! I'll try to implement that this week (rest of the workload permitting).
[llvm-debuginfo-analyzer] Use LLVM_BUILD_DEBUG in class definitions
LLVM_BUILD_DEBUG
in class definitions #140265[llvm-debuginfo-analyzer] Use LLVM_BUILD_DEBUG in class definitions
[llvm-debuginfo-analyzer] Use LLVM_BUILD_DEBUG in class definitions