Assert and crash in DefinitionData

I set a breakpoint on main, then type “expr set”, and hit this assert:

(lldb) expr set
lldb: /home/mikesart/data/src/llvm.hg/llvm/tools/clang/include/clang/AST/DeclCXX.h:553: struct DefinitionData &clang::CXXRecordDecl::data(): Assertion `DefinitionData && “queried property of class with no definition”’ failed.

DefinitionData is NULL. Log file shows the below. Full stacktrace is down below as well.

I don’t believe I’ve got any symbols named “set”, although this crash doesn’t happen with a much simpler hello_world test app.

If anyone has any suggestions on where to look, please let me know. Otherwise I’ll keep poking away here…
Thanks,
-Mike

8955 1373482599.140844 [66e2/7ff3afd86740]: HandleCommand, revised_command_line: ‘expr set’
8956 1373482599.140854 [66e2/7ff3afd86740]: HandleCommand, wants_raw_input:‘True’
8957 1373482599.140908 [66e2/7ff3afd86740]: HandleCommand, command line after removing command name(s): ‘set’
8958 1373482599.141033 [66e2/7ff3afd86740]: == [ClangUserExpression::Evaluate] Parsing expression set ==
8959 1373482599.141054 [66e2/7ff3afd86740]: ClangUserExpression::ScanContext()
8960 1373482599.141133 [66e2/7ff3afd86740]: Parsing the following code:
8961
8962 #undef NULL
8963 #undef Nil
8964 #undef nil
8965 #undef YES
8966 #undef NO
8967 #define NULL (__null)
8968 #define Nil (__null)
8969 #define nil (__null)
8970 #define YES ((BOOL)1)
8971 #define NO ((BOOL)0)
8972 typedef signed char BOOL;
8973 typedef signed INT8_TYPE int8_t;
8974 typedef unsigned INT8_TYPE uint8_t;
8975 typedef signed INT16_TYPE int16_t;
8976 typedef unsigned INT16_TYPE uint16_t;
8977 typedef signed INT32_TYPE int32_t;
8978 typedef unsigned INT32_TYPE uint32_t;
8979 typedef signed INT64_TYPE int64_t;
8980 typedef unsigned INT64_TYPE uint64_t;
8981 typedef signed INTPTR_TYPE intptr_t;
8982 typedef unsigned INTPTR_TYPE uintptr_t;
8983 typedef SIZE_TYPE size_t;
8984 typedef PTRDIFF_TYPE ptrdiff_t;
8985 typedef unsigned short unichar;
8986
8987
8988 void
8989 $__lldb_expr(void $__lldb_arg)
8990 {
8991 set;
8992 }
8993
8994 1373482599.143049 [66e2/7ff3afd86740]: LayoutRecordType[12] on (ASTContext
)0x2d0d650 for (RecordDecl*)0x2d1ea80 [name = ‘_objc_super’]
8995 1373482599.143353 [66e2/7ff3afd86740]: LayoutRecordType[13] on (ASTContext*)0x2d0d650 for (RecordDecl*)0x2d1ed20 [name = ‘_message_ref_t’]
8996 1373482599.145382 [66e2/7ff3afd86740]: FindExternalLexicalDecls[6] on (ASTContext*)0x2d0d650 in (TranslationUnitDecl*)0x2d1e3b0 with null predicate
8997 1373482599.145593 [66e2/7ff3afd86740]: TransformTopLevelDecl(BOOL)
8998 1373482599.145772 [66e2/7ff3afd86740]: TransformTopLevelDecl(int8_t)
8999 1373482599.145942 [66e2/7ff3afd86740]: TransformTopLevelDecl(uint8_t)
9000 1373482599.146113 [66e2/7ff3afd86740]: TransformTopLevelDecl(int16_t)
9001 1373482599.146281 [66e2/7ff3afd86740]: TransformTopLevelDecl(uint16_t)
9002 1373482599.146451 [66e2/7ff3afd86740]: TransformTopLevelDecl(int32_t)
9003 1373482599.146619 [66e2/7ff3afd86740]: TransformTopLevelDecl(uint32_t)
9004 1373482599.146803 [66e2/7ff3afd86740]: TransformTopLevelDecl(int64_t)
9005 1373482599.146999 [66e2/7ff3afd86740]: TransformTopLevelDecl(uint64_t)
9006 1373482599.147183 [66e2/7ff3afd86740]: TransformTopLevelDecl(intptr_t)
9007 1373482599.147360 [66e2/7ff3afd86740]: TransformTopLevelDecl(uintptr_t)
9008 1373482599.147539 [66e2/7ff3afd86740]: TransformTopLevelDecl(size_t)
9009 1373482599.147716 [66e2/7ff3afd86740]: TransformTopLevelDecl(ptrdiff_t)
9010 1373482599.147875 [66e2/7ff3afd86740]: TransformTopLevelDecl(unichar)
9011 1373482599.148093 [66e2/7ff3afd86740]: ClangExpressionDeclMap::FindExternalVisibleDecls[18] for ‘$__lldb_arg’ in a ‘TranslationUnit’
9012 1373482599.148118 [66e2/7ff3afd86740]: CEDM::FEVD[18] Searching the root namespace
9013 1373482599.148145 [66e2/7ff3afd86740]: ClangASTSource::FindExternalVisibleDecls[18] on (ASTContext*)0x2d0d650 for ‘$__lldb_arg’ in a ‘TranslationUnit’
9014 1373482599.148161 [66e2/7ff3afd86740]: CAS::FEVD[18] Searching the root namespace
9015 1373482599.148374 [66e2/7ff3afd86740]: ClangExpressionDeclMap::FindExternalVisibleDecls[19] for ‘$__lldb_expr’ in a ‘TranslationUnit’
9016 1373482599.148400 [66e2/7ff3afd86740]: CEDM::FEVD[19] Searching the root namespace
9017 1373482599.148424 [66e2/7ff3afd86740]: ClangASTSource::FindExternalVisibleDecls[19] on (ASTContext*)0x2d0d650 for ‘$__lldb_expr’ in a ‘TranslationUnit’
9018 1373482599.148438 [66e2/7ff3afd86740]: CAS::FEVD[19] Searching the root namespace
9019 1373482599.148726 [66e2/7ff3afd86740]: ClangExpressionDeclMap::FindExternalVisibleDecls[20] for ‘set’ in a ‘TranslationUnit’
9020 1373482599.148752 [66e2/7ff3afd86740]: CEDM::FEVD[20] Searching the root namespace

(gdb) bt
#0 0x00007f0800b38425 in __GI_raise (sig=) at …/nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007f0800b3bb8b in __GI_abort () at abort.c:91
#2 0x00007f0800b310ee in __assert_fail_base (fmt=, assertion=0x7f080565ec8a “DefinitionData && "queried property of class with no definition"”, file=0x7f0805
6cd817 “/home/mikesart/data/src/llvm.hg/llvm/tools/clang/include/clang/AST/DeclCXX.h”, line=, function=) at assert.c:94
#3 0x00007f0800b31192 in __GI___assert_fail (assertion=0x7f080565ec8a “DefinitionData && "queried property of class with no definition"”, file=0x7f08056cd817 “/home/mikesar
t/data/src/llvm.hg/llvm/tools/clang/include/clang/AST/DeclCXX.h”, line=553, function=0x7f08056cd8f9 “struct DefinitionData &clang::CXXRecordDecl::data()”) at assert.c:103
#4 0x00007f0803633e16 in clang::CXXRecordDecl::data (this=0x194ca40) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/include/clang/AST/DeclCXX.h:553
#5 0x00007f08036d205b in clang::CXXRecordDecl::addedMember (this=0x194ca40, D=0x1522100) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/AST/DeclCXX.cpp:411
#6 0x00007f08036c6423 in clang::DeclContext::addHiddenDecl (this=0x194ca78, D=0x1522100) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/AST/DeclBase.cpp:1108

#7 0x00007f08036c648d in clang::DeclContext::addDecl (this=0x194ca78, D=0x1522100) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/AST/DeclBase.cpp:1119
#8 0x00007f0803285cca in lldb_private::ClangASTContext::CreateRecordType (this=0x7f07d40017d8, decl_ctx=0x194ca78, access_type=lldb::eAccessPrivate, name=0x7f07edc5ffae “Erro
rCollector”, kind=3, language=lldb::eLanguageTypeUnknown, metadata=0x7fffbd00f3f0) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp:1182
#9 0x00007f08033bc0e3 in SymbolFileDWARF::ParseType (this=0x7f07d40059b0, sc=…, dwarf_cu=0x7f07d4068d40, die=0x12e5150, type_is_new_ptr=0x0) at /home/mikesart/data/src/llvm
.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:6157
#10 0x00007f08033b3961 in SymbolFileDWARF::GetTypeForDIE (this=0x7f07d40059b0, dwarf_cu=0x7f07d4068d40, die=0x12e5150) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/sourc
e/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4496
#11 0x00007f08033b373e in SymbolFileDWARF::ResolveType (this=0x7f07d40059b0, dwarf_cu=0x7f07d4068d40, type_die=0x12e5150, assert_not_being_parsed=true) at /home/mikesart/data/
src/llvm.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2652
#12 0x00007f08033aa418 in SymbolFileDWARF::ResolveTypeUID (this=0x7f07d40059b0, cu=0x7f07d4068d40, die=0x12e5150, assert_not_being_parsed=true) at /home/mikesart/data/src/llvm
.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2325
#13 0x00007f08033b17fe in SymbolFileDWARF::ResolveTypeUID (this=0x7f07d40059b0, type_uid=456429) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Plugins/SymbolFile/D
WARF/SymbolFileDWARF.cpp:2265
#14 0x00007f08032e96fc in lldb_private::Type::GetEncodingType (this=0x1522fa0) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Symbol/Type.cpp:316
#15 0x00007f08032e8f56 in lldb_private::Type::ResolveClangType (this=0x1522fa0, clang_type_resolve_state=lldb_private::Type::eResolveStateForward) at /home/mikesart/data/src/l
lvm.hg/llvm/tools/lldb/source/Symbol/Type.cpp:519
#16 0x00007f08032e9d9e in lldb_private::Type::GetClangForwardType (this=0x1522fa0) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Symbol/Type.cpp:681
#17 0x00007f08033b97ec in SymbolFileDWARF::ParseChildParameters (this=0x7f07d40059b0, sc=…, containing_decl_ctx=0x194c968, dwarf_cu=0x7f07d4068d40, parent_die=0x132a770, ski
p_artificial=true, is_static=@0x7fffbd010f35: false, type_list=0x7f07d4005938, function_param_types=…, function_param_decls=…, type_quals=@0x7fffbd010f20: 0, template_para
m_infos=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4279
#18 0x00007f08033bd3ca in SymbolFileDWARF::ParseType (this=0x7f07d40059b0, sc=…, dwarf_cu=0x7f07d4068d40, die=0x132a770, type_is_new_ptr=0x0) at /home/mikesart/data/src/llvm
.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:6507
#19 0x00007f08033b3961 in SymbolFileDWARF::GetTypeForDIE (this=0x7f07d40059b0, dwarf_cu=0x7f07d4068d40, die=0x132a770) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/sourc
e/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4496
#20 0x00007f08033b373e in SymbolFileDWARF::ResolveType (this=0x7f07d40059b0, dwarf_cu=0x7f07d4068d40, type_die=0x132a770, assert_not_being_parsed=true) at /home/mikesart/data/
src/llvm.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2652
#21 0x00007f08033aa418 in SymbolFileDWARF::ResolveTypeUID (this=0x7f07d40059b0, cu=0x7f07d4068d40, die=0x132a770, assert_not_being_parsed=true) at /home/mikesart/data/src/llvm
.hg/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2325
#22 0x00007f08033bf8de in SymbolFileDWARF::GetClangDeclContextForDIE (this=0x7f07d40059b0, sc=…, cu=0x7f07d4068d40, die=0x132a770) at /home/mikesart/data/src/llvm.hg/llvm/to
ols/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4605
#23 0x00007f08033b16f6 in SymbolFileDWARF::GetClangDeclContextForDIEOffset (this=0x7f07d40059b0, sc=…, die_offset=650576) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4531
#24 0x00007f08033bf7c0 in SymbolFileDWARF::GetClangDeclContextForDIE (this=0x7f07d40059b0, sc=…, cu=0x7f07d4068d40, die=0x13685c0) at /home/mikesart/data/src/llvm.hg/llvm/to
ols/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4594
#25 0x00007f08033b16f6 in SymbolFileDWARF::GetClangDeclContextForDIEOffset (this=0x7f07d40059b0, sc=…, die_offset=833179) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/
source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4531
#26 0x00007f08033bf80b in SymbolFileDWARF::GetClangDeclContextForDIE (this=0x7f07d40059b0, sc=…, cu=0x7f07d4068d40, die=0x1368610) at /home/mikesart/data/src/llvm.hg/llvm/to
ols/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4598

#27 0x00007f08033b16f6 in SymbolFileDWARF::GetClangDeclContextForDIEOffset (this=0x7f07d40059b0, sc=…, die_offset=833247) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/

source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:4531
#28 0x00007f08033b163a in SymbolFileDWARF::GetClangDeclContextForTypeUID (this=0x7f07d40059b0, sc=…, type_uid=833247) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/sour
ce/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:2250
#29 0x00007f08032c24b8 in lldb_private::Function::GetClangDeclContext (this=0x1840070) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Symbol/Function.cpp:451
#30 0x00007f08031cf0dc in lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls (this=0x1b3e190, context=…, module_sp=…, namespace_decl=…, current_id=2) at /hom
e/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Expression/ClangExpressionDeclMap.cpp:1329
#31 0x00007f08031cd6a6 in lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls (this=0x1b3e190, context=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/sourc
e/Expression/ClangExpressionDeclMap.cpp:872
#32 0x00007f0803203539 in lldb_private::ClangASTSource::FindExternalVisibleDeclsByName (this=0x1b3e190, decl_ctx=0x13b62f0, clang_decl_name=…) at /home/mikesart/data/src/llv
m.hg/llvm/tools/lldb/source/Expression/ClangASTSource.cpp:162
#33 0x00007f08031df7de in lldb_private::ClangASTSource::ClangASTSourceProxy::FindExternalVisibleDeclsByName(clang::DeclContext const*, clang::DeclarationName) () from /home/mi
kesart/data/src/llvm.hg/build/lib/liblldb.so.3.4
#34 0x00007f08036c6fba in clang::DeclContext::lookup (this=0x13b62f0, Name=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/AST/DeclBase.cpp:1242
#35 0x00007f08036c99f1 in clang::DeclContext::lookup (this=0x13b62f0, Name=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/include/clang/AST/DeclBase.h:1439
#36 0x00007f080403986a in LookupDirect (S=…, R=…, DC=0x13b62f0) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Sema/SemaLookup.cpp:673
#37 0x00007f0804038518 in CppNamespaceLookup (S=…, R=…, Context=…, NS=0x13b62f0, UDirs=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Sema/SemaLookup.cpp:7
65
#38 0x00007f0804037ba5 in clang::Sema::CppLookupName (this=0x13b98e0, R=…, S=0x13be3b0) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Sema/SemaLookup.cpp:1088
#39 0x00007f0804039499 in clang::Sema::LookupName (this=0x13b98e0, R=…, S=0x13ca620, AllowBuiltinCreation=true) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Sema/
SemaLookup.cpp:1261
#40 0x00007f080403a4ee in clang::Sema::LookupParsedName (this=0x13b98e0, R=…, S=0x13ca620, SS=0x7fffbd013ba8, AllowBuiltinCreation=true, EnteringContext=false) at /home/mike
sart/data/src/llvm.hg/llvm/tools/clang/lib/Sema/SemaLookup.cpp:1684
#41 0x00007f0803dff79f in clang::Sema::ClassifyName (this=0x13b98e0, S=0x13ca620, SS=…, Name=@0x7fffbd013b90: 0x13d5fa8, NameLoc=…, NextToken=…, IsAddressOfOperand=false
, CCC=0x7fffbd013da0) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Sema/SemaDecl.cpp:610
#42 0x00007f0803cb4cd8 in clang::Parser::TryAnnotateName (this=0x13bbfe0, IsAddressOfOperand=false, CCC=0x7fffbd013da0) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib
/Parse/Parser.cpp:1384
#43 0x00007f0803d25d3f in clang::Parser::ParseStatementOrDeclarationAfterAttributes (this=0x13bbfe0, Stmts=…, OnlyStatement=false, TrailingElseLoc=0x0, Attrs=…) at /home/m
ikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/ParseStmt.cpp:166
#44 0x00007f0803d25695 in clang::Parser::ParseStatementOrDeclaration (this=0x13bbfe0, Stmts=…, OnlyStatement=false, TrailingElseLoc=0x0) at /home/mikesart/data/src/llvm.hg/l
lvm/tools/clang/lib/Parse/ParseStmt.cpp:102
#45 0x00007f0803d2c4a0 in clang::Parser::ParseCompoundStatementBody (this=0x13bbfe0, isStmtExpr=false) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/ParseStmt.
cpp:843
#46 0x00007f0803d2f43f in clang::Parser::ParseFunctionStatementBody (this=0x13bbfe0, Decl=0x13c55a0, BodyScope=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Par
se/ParseStmt.cpp:2393
#47 0x00007f0803cb3f65 in clang::Parser::ParseFunctionDefinition (this=0x13bbfe0, D=…, TemplateInfo=…, LateParsedAttrs=0x7fffbd014aa8) at /home/mikesart/data/src/llvm.hg/l
lvm/tools/clang/lib/Parse/Parser.cpp:1118
#48 0x00007f0803ccb5d3 in clang::Parser::ParseDeclGroup (this=0x13bbfe0, DS=…, Context=0, AllowFunctionDefinitions=true, DeclEnd=0x0, FRI=0x0) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/ParseDecl.cpp:1622
#49 0x00007f0803cb3078 in clang::Parser::ParseDeclOrFunctionDefInternal (this=0x13bbfe0, attrs=…, DS=…, AS=clang::AS_none) at /home/mikesart/data/src/llvm.hg/llvm/tools/cl
ang/lib/Parse/Parser.cpp:896
#50 0x00007f0803cb2843 in clang::Parser::ParseDeclarationOrFunctionDefinition (this=0x13bbfe0, attrs=…, DS=0x0, AS=clang::AS_none) at /home/mikesart/data/src/llvm.hg/llvm/to
ols/clang/lib/Parse/Parser.cpp:912
#51 0x00007f0803cb2060 in clang::Parser::ParseExternalDeclaration (this=0x13bbfe0, attrs=…, DS=0x0) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/Parser.cpp:
777
#52 0x00007f0803cb125b in clang::Parser::ParseTopLevelDecl (this=0x13bbfe0, Result=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/Parser.cpp:582
#53 0x00007f0803cad102 in clang::ParseAST (S=…, PrintStats=false, SkipFunctionBodies=false) at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/ParseAST.cpp:144
#54 0x00007f0803caceaa in clang::ParseAST (PP=…, Consumer=0x1d30170, Ctx=…, PrintStats=false, TUKind=clang::TU_Complete, CompletionConsumer=0x0, SkipFunctionBodies=false)
at /home/mikesart/data/src/llvm.hg/llvm/tools/clang/lib/Parse/ParseAST.cpp:96
#55 0x00007f08031d904a in lldb_private::ClangExpressionParser::Parse (this=0x7fffbd016120, stream=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Expression/Cla
ngExpressionParser.cpp:400
#56 0x00007f0803196171 in lldb_private::ClangUserExpression::Parse (this=0x1cc8840, error_stream=…, exe_ctx=…, execution_policy=lldb_private::eExecutionPolicyOnlyWhenNeede
d, keep_result_in_memory=true) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp:504
#57 0x00007f0803197d4f in lldb_private::ClangUserExpression::EvaluateWithError (exe_ctx=…, execution_policy=lldb_private::eExecutionPolicyOnlyWhenNeeded, language=lldb::eLan
guageTypeUnknown, desired_type=lldb_private::ClangExpression::eResultTypeAny, unwind_on_error=true, ignore_breakpoints=true, expr_cstr=0xfdddd8 “set”, expr_prefix=0x0, result_
valobj_sp=…, error=…, run_others=true, timeout_usec=0) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp:1006
#58 0x00007f0803197b3c in lldb_private::ClangUserExpression::Evaluate (exe_ctx=…, execution_policy=lldb_private::eExecutionPolicyOnlyWhenNeeded, language=lldb::eLanguageType
Unknown, desired_type=lldb_private::ClangExpression::eResultTypeAny, unwind_on_error=true, ignore_breakpoints=true, expr_cstr=0xfdddd8 “set”, expr_prefix=0x0, result_valobj_sp
=…, run_others=true, timeout_usec=0) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Expression/ClangUserExpression.cpp:947
#59 0x00007f0803360671 in lldb_private::Target::EvaluateExpression (this=0x12812f0, expr_cstr=0xfdddd8 “set”, frame=0x7f07d772d3d0, result_valobj_sp=…, options=…) at /home
/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Target/Target.cpp:1889
#60 0x00007f0803509388 in lldb_private::CommandObjectExpression::EvaluateExpression (this=0xe875a0, expr=0xfdddd8 “set”, output_stream=0x127cfe0, error_stream=0x127d038, resul
t=0x127cfe0) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Commands/CommandObjectExpression.cpp:345
#61 0x00007f0803509d0e in lldb_private::CommandObjectExpression::DoExecute (this=0xe875a0, command=0xfdddd8 “set”, result=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/ll
db/source/Commands/CommandObjectExpression.cpp:528
#62 0x00007f080323b545 in lldb_private::CommandObjectRaw::Execute (this=0xe875a0, args_string=0xfdddd8 “set”, result=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/so
urce/Interpreter/CommandObject.cpp:1064
#63 0x00007f080322cca2 in lldb_private::CommandInterpreter::HandleCommand (this=0xe7f5f0, command_line=0x7f07e8000ed8 “expr set”, lazy_add_to_history=lldb_private::eLazyBoolYe
s, result=…, override_context=0x0, repeat_on_empty_command=true, no_context_switching=false) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/source/Interpreter/CommandInt
erpreter.cpp:1825
#64 0x00007f0802fe7404 in lldb::SBCommandInterpreter::HandleCommand (this=0x7fffbd017060, command_line=0x7f07e8000ed8 “expr set”, result=…, add_to_history=true) at /home/mik
esart/data/src/llvm.hg/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp:122
#65 0x000000000040bf50 in Driver::HandleIOEvent (this=0x7fffbd019d20, event=…) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/tools/driver/Driver.cpp:1083
#66 0x000000000040d8aa in Driver::MainLoop (this=0x7fffbd019d20) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/tools/driver/Driver.cpp:1556
#67 0x000000000040e0db in main (argc=1, argv=0x7fffbd019f28, envp=0x7fffbd019f38) at /home/mikesart/data/src/llvm.hg/llvm/tools/lldb/tools/driver/Driver.cpp:1727

Turned on dwarf logging, and it looks like it’s dying with some of the protobuf library symbols. The last output is:

With C++ classes we always will create the class, but we don't start the clang RecordDecl definition of the class until someone somewhere asks for information about the class that requires it to complete. The SymbolFileDWARF is a ExternalASTSource that knows how to complete its classes so when someone asks the class to complete, it should call into the SymbolFileDWARF plug-in (from the clang AST code) through one of:

SymbolFileDWARF::CompleteTagDecl (void *baton, clang::TagDecl *decl)
SymbolFileDWARF::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)

This will call into:

lldb::clang_type_t
SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type)

This code:
1 - starts the definition
2 - parses all members (ivars, methods, etc)
3 - completes the definition

What is happening here is you have something like:

class A
{
    class B
    {
    };
};

We are trying to create "B" here and it thinks that "A" must be complete before it can be added. In your code the "decl_ctx" that is passed to ClangASTContext::CreateRecordType() is for a class that has not been completed. I am pretty sure we didn't used to require type "A" to be complete before adding "B" as a decl in "A". Can we check if anything changed in clang recently? If no changes to clang were recently made, the solution is to call:

SymbolFileDWARF::CompleteTagDecl (this, decl_ctx);

To ensure the decl context is complete just before calling CXXRecordDecl::Create(). We want to avoid doing this it at all possible, so please do check for any clang changes first.

Greg

Turned on dwarf logging, and it looks like it's dying with some of the protobuf library symbols. The last output is:

206694 1373493358.162653 [4ed3/7f542e5a5740]: (x86_64) /usr/local/lib/libprotobuf.so.8: SymbolFileDWARF::ResolveTypeUID (die = 0x0006f6ed) DW_TAG_class_type 'ErrorCollector'
206695 1373493358.162667 [4ed3/7f542e5a5740]: (x86_64) /usr/local/lib/libprotobuf.so.8: SymbolFileDWARF::ResolveTypeUID (die = 0x0006f6ed) DW_TAG_class_type 'ErrorCollector' resolve parent forward type for 0x0006f6e3
206696 1373493358.162681 [4ed3/7f542e5a5740]: (x86_64) /usr/local/lib/libprotobuf.so.8: SymbolFileDWARF::ParseType (die = 0x0006f6ed, decl_ctx = 0x19b3e58 (die 0x0006f6e3)) DW_TAG_class_type name = 'ErrorCollector')

This happens if I try to print several of the protobuf member functions: "p set_name", "p CopyFrom", "p MergeFrom", etc.

I don't understand a bunch of the code here yet, but this is the bit that's dying:

1105| // Notify a C++ record declaration that we've added a member, so it can
1106| // update it's class-specific state.
1107| if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(this))
1108+> Record->addedMember(D);

addedMember() is being called, but Record has no definition. It calls down into this, and line 411 dies.

405| void CXXRecordDecl::addedMember(Decl *D) {
406| if (!D->isImplicit() &&
407| !isa<FieldDecl>(D) &&
408| !isa<IndirectFieldDecl>(D) &&
409| (!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() == TTK_Class ||
410| cast<TagDecl>(D)->getTagKind() == TTK_Interface))
411+> data().HasOnlyCMembers = false;
412|
413| // Ignore friends and invalid declarations.
414| if (D->getFriendObjectKind() || D->isInvalidDecl())
415| return;

This is bit of lldb code that is calling into clang:

1161| // NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and
1162| // we will need to update this code. I was told to currently always use
1163| // the CXXRecordDecl class since we often don't know from debug information
1164| // if something is struct or a class, so we default to always use the more
1165| // complete definition just in case.
1166| CXXRecordDecl *decl = CXXRecordDecl::Create (*ast,
1167| (TagDecl::TagKind)kind,
1168| decl_ctx,
1169| SourceLocation(),
1170| SourceLocation(),
1171| name && name[0] ? &ast->Idents.get(name) : NULL);
1172|
1173| if (decl)
1174| {
1175| if (metadata)
1176| SetMetadata(ast, decl, *metadata);
1177|
1178| if (access_type != eAccessNone)
1179| decl->setAccess (ConvertAccessTypeToAccessSpecifier (access_type));
1180|
1181| if (decl_ctx)
1182+> decl_ctx->addDecl (decl);

If I change the addDecl check to this, I don't crash anymore:

        if (decl_ctx && decl->hasDefinition())
            decl_ctx->addDecl (decl);

Anyone have any insights as to the right approach here?

We can't do this, otherwise the decl will never be added tot he record decl and it will hose up name lookup during expressions.

We need to make sure the definition has been started. Getting a stack trace for where this is happening should show if this is being done under SymbolFileDWARF::ResolveClangOpaqueTypeDefinition ().

Correction to this:

When we create a C++ class we start the definition right away, we don't do this for ObjC classes (since they don't inherit from TagDecl which has a isComplete() accessor) for the very reason that we are running into here. The SymbolFileDWARF::ResolveClangOpaqueTypeDefinition() then will:

1 - starts the definition for ObjC classes only (C++ classes get their definition started right away)
2 - parses all members (ivars, methods, etc)
3 - completes the definition

We want to avoid doing this it at all possible, so please do check for any clang changes first.

I went back three months ago (r179296) and it didn’t crash. Doing the bsod narrowed it down to 180048. (Full clean build with 180047 doesn’t crash).

However this change doesn’t have anything to do with clang. I’m guessing the symbols just weren’t found before this change?

If I add this change to 179296, that crashes as well.

How far back should I be looking for this clang change, if that’s it?
Thanks Greg.
-Mike

mikesart@mikesart-rad:~/data/src/llvm.svn/llvm/tools/lldb$ svn log -r 180048

r180048 | mkopec | 2013-04-22 14:13:22 -0700 (Mon, 22 Apr 2013) | 4 lines

When parsing dwarf, add C functions to the fullname index.

This fixes function type resolution for C functions when requesting full function names.

mikesart@mikesart-rad:~/data/src/llvm.svn/llvm/tools/lldb$ svn diff -r 180047:180048

Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp

As long as we have an explanation for why it is now happening we are good.

So does completing the type using the decl_ctx fix the issue? Falling back to what I said before, we do start the C++ class definition right away. Some code checks for a complete definition and other code checks for the definition being started. We might want to verify that clang is correct to assert in this case (by making sure clang requires a full definition). If it does, then we need to complete the type prior to adding to it.