[Lldb-commits] [lldb] [lldb] Fix assertion caused by invalid SupportFileSP (PR #162710)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 9 11:04:41 PDT 2025


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/162710

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

>From 8a1d0c64075ad62f0a4c22a06cf3fd4487a6bdff Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Thu, 9 Oct 2025 11:00:36 -0700
Subject: [PATCH] [lldb] Fix assertion caused by invalid SupportFileSP

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
---
 lldb/source/Symbol/Function.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;



More information about the lldb-commits mailing list