[llvm-branch-commits] [lldb] 2c7b58a - Use static_pointer_cast to do SyntheticChildrenSP -> ScriptedSyntheticChildrenSP (#216181)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 27 00:51:45 PDT 2026
Author: jimingham
Date: 2026-08-27T09:51:27+02:00
New Revision: 2c7b58a3bbb190da00ca00c02819fd3a5b6d036e
URL: https://github.com/llvm/llvm-project/commit/2c7b58a3bbb190da00ca00c02819fd3a5b6d036e
DIFF: https://github.com/llvm/llvm-project/commit/2c7b58a3bbb190da00ca00c02819fd3a5b6d036e.diff
LOG: Use static_pointer_cast to do SyntheticChildrenSP -> ScriptedSyntheticChildrenSP (#216181)
FormatManager::GetSyntheticForType was taking a pointer out one shared
pointer and making a new shared pointer referring to it which messes up
the lifecycle of the object.
This is just a little thinko from the original implementation. We do the
same thing in several other places in the TypeCategory, etc. and it's
done correctly in all the other places.
I'm not adding a test here because trying to guess what you have to do
to cause one or the other shared_pointer to get their reference count to
0 isn't particularly stable.
The testing for SBTypeSynthetic is pretty minimal - it would be better
to write a complete test for this class, which would have tripped this.
But that's a bigger task, and I want to get this obvious crasher fix in
now.
This fixes:
github.com/llvm/llvm-project/issues/213628
(cherry picked from commit ae3ea1b11857e54ea904c79e17b0ddc0a19a8020)
Added:
Modified:
lldb/source/DataFormatters/FormatManager.cpp
Removed:
################################################################################
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index 6342fd89cc9be..e9f0e51e34149 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -388,14 +388,14 @@ FormatManager::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
category_sp = GetCategoryAtIndex(category_id);
if (!category_sp->IsEnabled())
continue;
- lldb::ScriptedSyntheticChildrenSP synth_current_sp(
- (ScriptedSyntheticChildren *)category_sp->GetSyntheticForType(type_sp)
- .get());
- if (synth_current_sp &&
+ auto synth_current_sp = category_sp->GetSyntheticForType(type_sp);
+
+ if (synth_current_sp && synth_current_sp->IsScripted() &&
(synth_chosen_sp.get() == nullptr ||
(prio_category > category_sp->GetEnabledPosition()))) {
prio_category = category_sp->GetEnabledPosition();
- synth_chosen_sp = synth_current_sp;
+ synth_chosen_sp =
+ std::static_pointer_cast<ScriptedSyntheticChildren>(synth_current_sp);
}
}
return synth_chosen_sp;
More information about the llvm-branch-commits
mailing list