llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: None (jeffreytan81) <details> <summary>Changes</summary> https://github.com/llvm/llvm-project/pull/68012/files added new data formatters for LibStdC++ std::variant. However, this formatter can crash if std::variant's index field has invalid value (exceeds the number of template arguments). This can happen if the current IP stops at a place std::variant is not initialized yet. This patch fixes the crash by ensuring the index is a valid value. --- Full diff: https://github.com/llvm/llvm-project/pull/69253.diff 1 Files Affected: - (modified) lldb/examples/synthetic/gnu_libstdcpp.py (+5) ``````````diff diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 29c926167fb440c..f778065aaca3771 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -914,6 +914,11 @@ def get_variant_npos_value(index_byte_size): if index == npos_value: return " No Value" + # Invalid index can happen when the variant is not initialized yet. + template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments() + if index >= template_arg_count: + return " <Invalid>" + active_type = data_obj.GetType().GetTemplateArgumentType(index) return f" Active Type = {active_type.GetDisplayTypeName()} " `````````` </details> https://github.com/llvm/llvm-project/pull/69253 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits