<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - lldb crashes with relatively simple gcc debug info"
href="https://bugs.llvm.org/show_bug.cgi?id=51818">51818</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lldb crashes with relatively simple gcc debug info
</td>
</tr>
<tr>
<th>Product</th>
<td>lldb
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>lldb-dev@lists.llvm.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jgorbe@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Building the following program with gcc 10.2.1:
```
#include <optional>
#include <string>
int main()
{
std::optional<std::string> os{ "stringy" };
return 0;
}
```
and trying to `print os` from lldb, results in infinite recursion inside
`clang::ASTContext::getASTRecordLayout` leading to a crash.
I have investigated this for a while and I got to the following reduced test
case:
```
template <bool> struct S {};
template <> struct S<false> : S<true> {};
S<false> s;
```
What happens is that gcc omits `DW_TAG_template_parameter` in some cases (for
unnamed template arguments, it seems). lldb passes clang an AST that says that
S<false> is a struct S that inherits from S<>, and clang recurses infinitely
trying to compute the class layout. This is the AST as dumped by lldb-test
symbols -dump-clang-ast:
Module: cxx17.o
S<true>
ClassTemplateSpecializationDecl 0xf2571d0 <<invalid sloc>> <invalid sloc>
struct S definition
`-DefinitionData pass_in_registers empty aggregate standard_layout
trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor
can_const_default_init
|-DefaultConstructor exists trivial constexpr needs_implicit
defaulted_is_constexpr
|-CopyConstructor simple trivial has_const_param needs_implicit
implicit_has_const_param
|-MoveConstructor exists simple trivial needs_implicit
|-CopyAssignment simple trivial has_const_param needs_implicit
implicit_has_const_param
|-MoveAssignment exists simple trivial needs_implicit
`-Destructor simple irrelevant trivial needs_implicit
S<false>
ClassTemplateSpecializationDecl 0xf257340 <<invalid sloc>> <invalid sloc>
struct S definition
|-DefinitionData pass_in_registers empty standard_layout trivially_copyable
trivial literal has_constexpr_non_copy_move_ctor can_const_default_init
| |-DefaultConstructor exists trivial constexpr needs_implicit
defaulted_is_constexpr
| |-CopyConstructor simple trivial has_const_param needs_implicit
implicit_has_const_param
| |-MoveConstructor exists simple trivial needs_implicit
| |-CopyAssignment simple trivial has_const_param needs_implicit
implicit_has_const_param
| |-MoveAssignment exists simple trivial needs_implicit
| `-Destructor simple irrelevant trivial needs_implicit
`-public 'S<>'
`getASTRecordLayout` tries to create an `EmptySubobjectMap`, and its
constructor calls `ComputeEmptySubobjectSizes`. This function enumerates the
base classes of the current class, and calls `getASTRecordLayout` again. Here's
a relevant fragment of a stack trace:
[... 6993 more frames of these 3 functions recursing ...]
#6994 0x00007ffff5d7a05a in (anonymous
namespace)::EmptySubobjectMap::EmptySubobjectMap (this=0x7fffffff3df8,
Context=..., Class=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:172
#6995 0x00007ffff5d79687 in clang::ASTContext::getASTRecordLayout
(this=0x6a5e80, D=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:3290
#6996 0x00007ffff5d7f5e1 in (anonymous
namespace)::EmptySubobjectMap::ComputeEmptySubobjectSizes (this=0x7fffffff4bf8)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:193
#6997 0x00007ffff5d7a05a in (anonymous
namespace)::EmptySubobjectMap::EmptySubobjectMap (this=0x7fffffff4bf8,
Context=..., Class=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:172
#6998 0x00007ffff5d79687 in clang::ASTContext::getASTRecordLayout
(this=0x6a5e80, D=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:3290
#6999 0x00007ffff5d7f5e1 in (anonymous
namespace)::EmptySubobjectMap::ComputeEmptySubobjectSizes (this=0x7fffffff59f8)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:193
#7000 0x00007ffff5d7a05a in (anonymous
namespace)::EmptySubobjectMap::EmptySubobjectMap (this=0x7fffffff59f8,
Context=..., Class=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:172
#7001 0x00007ffff5d79687 in clang::ASTContext::getASTRecordLayout
(this=0x6a5e80, D=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/AST/RecordLayoutBuilder.cpp:3290
#7002 0x00007ffff2bfc53f in (anonymous
namespace)::CGRecordLowering::CGRecordLowering (this=0x7fffffff60a0, Types=...,
D=0x6f2500, Packed=false)
at /home/jgorbe/code/llvm/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:234
#7003 0x00007ffff2bfb8d9 in clang::CodeGen::CodeGenTypes::ComputeRecordLayout
(this=0x6c09f8, D=0x6f2500, Ty=0x6c3170)
at /home/jgorbe/code/llvm/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:879
#7004 0x00007ffff267324f in clang::CodeGen::CodeGenTypes::ConvertRecordDeclType
(this=0x6c09f8, RD=0x6f2500)
at /home/jgorbe/code/llvm/clang/lib/CodeGen/CodeGenTypes.cpp:851
[...]</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>