[Bug 47868] New: LLDB crashes on command completions

Bug ID 47868
Summary LLDB crashes on command completions
Product lldb
Version unspecified
Hardware PC
OS Linux
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter luis@penagos.co
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

Created attachment 24069 [details]
A toy function LLVM bitcode

OS: Linux Mint 20 Ulyana
Build target: x86_64-unknown-linux-gnu (posix)
Python version: Python 3.8.5
LLDB version: 12.0.0
  clang revision 5502cfa091e0f6b35a6d96435b2ec15a43a324eb
  llvm revision 5502cfa091e0f6b35a6d96435b2ec15a43a324eb

When debugging the loop fusion pass in LLVM's opt executable, I am seeing LLDB
crash on command completions. Both LLDB and OPT were compiled with a clang
toolchain on Linux with full debug symbols. The attached bitcode was generated
with the command:

$ clang -static --target=mipsel-linux-gnu -emit-llvm test.c -c -O0 -o test.bc

Repro steps (test.bc included in attachments):

$ lldb opt
(lldb) b runOnFunction
(lldb) process launch -i test.bc -o /dev/null -- --loop-fusion
(lldb) up
(lldb) p Pass<TAB><TAB>

Results in LLDB crashing with the stacktrace below:

Stack dump:
0.      Program arguments: lldb opt 
 #0 0x000000000039663a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/home/luis/proj/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:11
 #1 0x00000000003967db PrintStackTraceSignalHandler(void*)
/home/luis/proj/llvm-project/llvm/lib/Support/Unix/Signals.inc:627:1
 #2 0x0000000000395049 llvm::sys::RunSignalHandlers()
/home/luis/proj/llvm-project/llvm/lib/Support/Signals.cpp:69:5
 #3 0x0000000000396ee1 SignalHandler(int)
/home/luis/proj/llvm-project/llvm/lib/Support/Unix/Signals.inc:405:1
 #4 0x00007fcb0ab6b3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #5 0x00007fcb075eb23c clang::Decl::getIdentifierNamespace() const
/home/luis/proj/llvm-project/clang/include/clang/AST/DeclBase.h:815:12
 #6 0x00007fcb079a6c88 clang::Decl::isInIdentifierNamespace(unsigned int) const
/home/luis/proj/llvm-project/clang/include/clang/AST/DeclBase.h:819:37
 #7 0x00007fcb0822e057
clang::LookupResult::getAcceptableDecl(clang::NamedDecl*) const
/home/luis/proj/llvm-project/clang/include/clang/Sema/Lookup.h:362:9
 #8 0x00007fcb086f2841 (anonymous
namespace)::LookupVisibleHelper::lookupInDeclContext(clang::DeclContext*,
clang::LookupResult&, bool, bool)
/home/luis/proj/llvm-project/clang/lib/Sema/SemaLookup.cpp:3770:19
 #9 0x00007fcb086f1d0c (anonymous
namespace)::LookupVisibleHelper::lookupInScope(clang::Scope*,
clang::LookupResult&, (anonymous namespace)::UnqualUsingDirectiveSet&)
/home/luis/proj/llvm-project/clang/lib/Sema/SemaLookup.cpp:3930:18
#10 0x00007fcb086e1da4 (anonymous
namespace)::LookupVisibleHelper::lookupVisibleDecls(clang::Sema&,
clang::Scope*, clang::Sema::LookupNameKind, bool)
/home/luis/proj/llvm-project/clang/lib/Sema/SemaLookup.cpp:3700:3
#11 0x00007fcb086e1b40 clang::Sema::LookupVisibleDecls(clang::Scope*,
clang::Sema::LookupNameKind, clang::VisibleDeclConsumer&, bool, bool)
/home/luis/proj/llvm-project/clang/lib/Sema/SemaLookup.cpp:4001:1
#12 0x00007fcb07dc21a7 clang::Sema::CodeCompleteOrdinaryName(clang::Scope*,
clang::Sema::ParserCompletionContext)
/home/luis/proj/llvm-project/clang/lib/Sema/SemaCodeComplete.cpp:4165:3
#13 0x00007fcb0796ccfc
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
/home/luis/proj/llvm-project/clang/lib/Parse/ParseStmt.cpp:174:13
#14 0x00007fcb0796ca97
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
/home/luis/proj/llvm-project/clang/lib/Parse/ParseStmt.cpp:106:20
#15 0x00007fcb07974825 clang::Parser::ParseCompoundStatementBody(bool)
/home/luis/proj/llvm-project/clang/lib/Parse/ParseStmt.cpp:1098:11
#16 0x00007fcb07975ca8 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
/home/luis/proj/llvm-project/clang/lib/Parse/ParseStmt.cpp:2259:21
#17 0x00007fcb078cacb5
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
/home/luis/proj/llvm-project/clang/lib/Parse/Parser.cpp:1375:3
#18 0x00007fcb0790e9a1 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
/home/luis/proj/llvm-project/clang/lib/Parse/ParseDecl.cpp:1924:27
#19 0x00007fcb078c9c01
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/home/luis/proj/llvm-project/clang/lib/Parse/Parser.cpp:1135:10
#20 0x00007fcb078c9250
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/home/luis/proj/llvm-project/clang/lib/Parse/Parser.cpp:1151:12
#21 0x00007fcb078c8b41
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/home/luis/proj/llvm-project/clang/lib/Parse/Parser.cpp:971:12
#22 0x00007fcb078c6ede
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
/home/luis/proj/llvm-project/clang/lib/Parse/Parser.cpp:716:12
#23 0x00007fcb078c27f7 clang::ParseAST(clang::Sema&, bool, bool)
/home/luis/proj/llvm-project/clang/lib/Parse/ParseAST.cpp:158:16
#24 0x00007fcb05c301e0
lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&,
clang::CodeCompleteConsumer*, unsigned int, unsigned int)
/home/luis/proj/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:1107:5
#25 0x00007fcb05c2f41b
lldb_private::ClangExpressionParser::Complete(lldb_private::CompletionRequest&,
unsigned int, unsigned int, unsigned int)
/home/luis/proj/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:961:21
#26 0x00007fcb05c8f9b3
lldb_private::ClangUserExpression::Complete(lldb_private::ExecutionContext&,
lldb_private::CompletionRequest&, unsigned int)
/home/luis/proj/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp:832:3
#27 0x00007fcb05af5be3
lldb_private::CommandObjectExpression::HandleCompletion(lldb_private::CompletionRequest&)
/home/luis/proj/llvm-project/lldb/source/Commands/CommandObjectExpression.cpp:352:1
#28 0x00007fcb031f766a
lldb_private::CommandAlias::HandleCompletion(lldb_private::CompletionRequest&)
/home/luis/proj/llvm-project/lldb/source/Interpreter/CommandAlias.cpp:122:1
#29 0x00007fcb031d4966
lldb_private::CommandInterpreter::HandleCompletionMatches(lldb_private::CompletionRequest&)
/home/luis/proj/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1859:3
#30 0x00007fcb031d4aba
lldb_private::CommandInterpreter::HandleCompletion(lldb_private::CompletionRequest&)
/home/luis/proj/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:1882:1
#31 0x00007fcb030a447f
lldb_private::IOHandlerDelegate::IOHandlerComplete(lldb_private::IOHandler&,
lldb_private::CompletionRequest&)
/home/luis/proj/llvm-project/lldb/source/Core/IOHandler.cpp:214:5
#32 0x00007fcb030a497c
lldb_private::IOHandlerEditline::AutoCompleteCallback(lldb_private::CompletionRequest&,
void*) /home/luis/proj/llvm-project/lldb/source/Core/IOHandler.cpp:459:1
#33 0x00007fcb03196a3d lldb_private::Editline::TabCommand(int)
/home/luis/proj/llvm-project/lldb/source/Host/common/Editline.cpp:993:65
#34 0x00007fcb03199d27
lldb_private::Editline::ConfigureEditor(bool)::$_14::operator()(editline*, int)
const /home/luis/proj/llvm-project/lldb/source/Host/common/Editline.cpp:1197:5
#35 0x00007fcb03199ceb
lldb_private::Editline::ConfigureEditor(bool)::$_14::__invoke(editline*, int)
/home/luis/proj/llvm-project/lldb/source/Host/common/Editline.cpp:1195:51
#36 0x00007fcafc38dd42 el_wgets
(/usr/lib/x86_64-linux-gnu/libedit.so.2+0x10d42)
#37 0x00007fcb03198fa5
lldb_private::Editline::GetLine(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, bool&)
/home/luis/proj/llvm-project/lldb/source/Host/common/Editline.cpp:1497:16
#38 0x00007fcb030a4cce
lldb_private::IOHandlerEditline::GetLine(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, bool&)
/home/luis/proj/llvm-project/lldb/source/Core/IOHandler.cpp:334:10
#39 0x00007fcb030a595a lldb_private::IOHandlerEditline::Run()
/home/luis/proj/llvm-project/lldb/source/Core/IOHandler.cpp:575:11
#40 0x00007fcb0306c951 lldb_private::Debugger::RunIOHandlers()
/home/luis/proj/llvm-project/lldb/source/Core/Debugger.cpp:861:16
#41 0x00007fcb031d97d4
lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&)
/home/luis/proj/llvm-project/lldb/source/Interpreter/CommandInterpreter.cpp:3073:9
#42 0x00007fcb02a01709 lldb::SBDebugger::RunCommandInterpreter(bool, bool)
/home/luis/proj/llvm-project/lldb/source/API/SBDebugger.cpp:1170:42
#43 0x000000000028d295 Driver::MainLoop()
/home/luis/proj/llvm-project/lldb/tools/driver/Driver.cpp:674:3
#44 0x000000000028e253 main
/home/luis/proj/llvm-project/lldb/tools/driver/Driver.cpp:921:17
#45 0x00007fcafcb5a0b3 __libc_start_main
/build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#46 0x000000000028a59e _start (/usr/local/bin/lldb+0x28a59e)
Segmentation fault (core dumped)