Skip to content

Conversation

JDevlieghere
Copy link
Member

SupportFileSP should never be null, and instead should use a default constructed SupportFile to represent an invalid instance. This is because the class used to be a value type before it became polymorphic.

We have various places in LLDB where we check this precondition, including in DisplaySourceLinesWithLineNumbers. The assertion was tripped when calling GetStartLineSourceInfo which starts by resetting the SupportFileSP and has a series of early returns which leave the shared pointer in that state.

rdar://161607247

SupportFileSP should never be null, and instead should use a default
constructed SupportFile to represent an invalid instance. This is
because the class used to be a value type before it became polymorphic.

We have various places in LLDB where we check this precondition,
including in DisplaySourceLinesWithLineNumbers. The assertion was
tripped when calling GetStartLineSourceInfo which starts by resetting
the SupportFileSP and has a series of early returns which leave the
shared pointer in that state.

rdar://161607247
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

SupportFileSP should never be null, and instead should use a default constructed SupportFile to represent an invalid instance. This is because the class used to be a value type before it became polymorphic.

We have various places in LLDB where we check this precondition, including in DisplaySourceLinesWithLineNumbers. The assertion was tripped when calling GetStartLineSourceInfo which starts by resetting the SupportFileSP and has a series of early returns which leave the shared pointer in that state.

rdar://161607247


Full diff: https://github.com/llvm/llvm-project/pull/162710.diff

1 Files Affected:

  • (modified) lldb/source/Symbol/Function.cpp (+1-1)
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 6114eccd935ee..2be1e389aa1d0 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -275,7 +275,7 @@ Function::~Function() = default;
 void Function::GetStartLineSourceInfo(SupportFileSP &source_file_sp,
                                       uint32_t &line_no) {
   line_no = 0;
-  source_file_sp.reset();
+  source_file_sp = std::make_shared<SupportFile>();
 
   if (m_comp_unit == nullptr)
     return;

@JDevlieghere JDevlieghere merged commit eb06c7e into llvm:main Oct 9, 2025
11 checks passed
@JDevlieghere JDevlieghere deleted the rdar161607247 branch October 9, 2025 19:05
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Oct 9, 2025
SupportFileSP should never be null, and instead should use a default
constructed SupportFile to represent an invalid instance. This is
because the class used to be a value type before it became polymorphic.

We have various places in LLDB where we check this precondition,
including in DisplaySourceLinesWithLineNumbers. The assertion was
tripped when calling GetStartLineSourceInfo which starts by resetting
the SupportFileSP and has a series of early returns which leave the
shared pointer in that state.

rdar://161607247
(cherry picked from commit eb06c7e)
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Oct 10, 2025
[lldb] Fix assertion caused by invalid SupportFileSP (llvm#162710)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants