[lldb-dev] Stackoverflow crash when evaluating an invalid expression

Ben Ruthig via lldb-dev lldb-dev at lists.llvm.org
Thu Feb 28 07:47:40 PST 2019


Hello all,

I am currently investigating an issue where LLDB is crashing due to a stack
overflow when attempting to evaluate an expression.  I have seen the same
issue in 6.0.1 and have reproduced it in 7.0.1.  Any help to diagnose and
fix would be greatly appreciated as I am trying to meet a release deadline
early next week!

The facts:
- The expression being evaluated is not a valid expression in the C++
domain. For example the expression is a datatype like 'Foobar'.  (For
reasons unexplained I am constrained to supporting this use case.)
- The crash occurs when using the C++ LLDB API but not when trying to
evaluate the expression via the LLDB shell or the LLDB Python script
shell.  However, when doing 'expr Foobar' there is no output and the
operation is completely silent.  It is similar when trying to do
'lldb.frame.EvaluateExpression("Foobar")'
in the Python shell as well.  I would expect to get some error output or an
SbValue in an error state but no such luck.
- I was able to capture a stack trace (attached) and it seems to be a
recursive loop bottoming out.  For brevity two 'loops' of stacktrace are
included here:

3387.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const
clang::RecordDecl * D) Line 2965    C++
3388.      liblldb.dll!`anonymous
namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes() Line 216    C++
3389.      liblldb.dll!`anonymous
namespace'::EmptySubobjectMap::EmptySubobjectMap(const clang::ASTContext &
Context, const clang::CXXRecordDecl * Class) Line 172    C++
3390.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const
clang::RecordDecl * D) Line 2965    C++
3391.      liblldb.dll!`anonymous
namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes() Line 216    C++
3392.      liblldb.dll!`anonymous
namespace'::EmptySubobjectMap::EmptySubobjectMap(const clang::ASTContext &
Context, const clang::CXXRecordDecl * Class) Line 172    C++
3393.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const
clang::RecordDecl * D) Line 2965    C++

Help please :S

Thanks,
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190228/93daafa6/attachment-0001.html>
-------------- next part --------------
...
3384.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const clang::RecordDecl * D) Line 2965    C++
3385.      liblldb.dll!`anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes() Line 216    C++
3386.      liblldb.dll!`anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap(const clang::ASTContext & Context, const clang::CXXRecordDecl * Class) Line 172    C++
3387.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const clang::RecordDecl * D) Line 2965    C++
3388.      liblldb.dll!`anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes() Line 216    C++
3389.      liblldb.dll!`anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap(const clang::ASTContext & Context, const clang::CXXRecordDecl * Class) Line 172    C++
3390.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const clang::RecordDecl * D) Line 2965    C++
3391.      liblldb.dll!`anonymous namespace'::EmptySubobjectMap::ComputeEmptySubobjectSizes() Line 216    C++
3392.      liblldb.dll!`anonymous namespace'::EmptySubobjectMap::EmptySubobjectMap(const clang::ASTContext & Context, const clang::CXXRecordDecl * Class) Line 172    C++
3393.      liblldb.dll!clang::ASTContext::getASTRecordLayout(const clang::RecordDecl * D) Line 2965    C++
3394.      liblldb.dll!`anonymous namespace'::CGRecordLowering::CGRecordLowering(clang::CodeGen::CodeGenTypes & Types, const clang::RecordDecl * D, bool Packed) Line 220    C++
3395.      liblldb.dll!clang::CodeGen::CodeGenTypes::ComputeRecordLayout(const clang::RecordDecl * D, llvm::StructType * Ty) Line 726    C++
3396.      liblldb.dll!clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(const clang::RecordDecl * RD) Line 709    C++
3397.      liblldb.dll!clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(const clang::RecordDecl * RD) Line 705    C++
3398.      liblldb.dll!clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType T) Line 390    C++
3399.      liblldb.dll!clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType T) Line 88    C++
3400.      liblldb.dll!clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType T) Line 518    C++
3401.      liblldb.dll!`anonymous namespace'::X86_64ABIInfo::classifyArgumentType(clang::QualType Ty, unsigned int freeIntRegs, unsigned int & neededInt, unsigned int & neededSSE, bool isNamedArg) Line 3394    C++
3402.      liblldb.dll!`anonymous namespace'::X86_64ABIInfo::computeInfo(clang::CodeGen::CGFunctionInfo & FI) Line 3591    C++
3403.      liblldb.dll!clang::CodeGen::CodeGenTypes::arrangeLLVMFunctionInfo(clang::CanQual<clang::Type> resultType, bool instanceMethod, bool chainCall, llvm::ArrayRef<clang::CanQual<clang::Type> > argTypes, clang::FunctionType::ExtInfo info, llvm::ArrayRef<clang::FunctionProtoType::ExtParameterInfo> paramInfos, clang::CodeGen::RequiredArgs required) Line 769    C++
3404.      liblldb.dll!arrangeLLVMFunctionInfo(clang::CodeGen::CodeGenTypes & CGT, bool instanceMethod, llvm::SmallVectorImpl<clang::CanQual<clang::Type> > & prefix, clang::CanQual<clang::FunctionProtoType> FTP, const clang::FunctionDecl * FD) Line 178    C++
3405.      liblldb.dll!clang::CodeGen::CodeGenTypes::arrangeCXXMethodType(const clang::CXXRecordDecl * RD, const clang::FunctionProtoType * FTP, const clang::CXXMethodDecl * MD) Line 253    C++
3406.      liblldb.dll!clang::CodeGen::CodeGenTypes::arrangeCXXMethodDeclaration(const clang::CXXMethodDecl * MD) Line 272    C++
3407.      liblldb.dll!clang::CodeGen::CodeGenTypes::arrangeFunctionDeclaration(const clang::FunctionDecl * FD) Line 422    C++
3408.      liblldb.dll!clang::CodeGen::CodeGenTypes::arrangeGlobalDeclaration(clang::GlobalDecl GD) Line 508    C++
3409.      liblldb.dll!clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl GD, llvm::GlobalValue * GV) Line 3553    C++
3410.      liblldb.dll!clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl GD, llvm::GlobalValue * GV) Line 2271    C++
3411.      liblldb.dll!clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl GD) Line 2054    C++
3412.      liblldb.dll!clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl * D) Line 4318    C++
3413.      liblldb.dll!`anonymous namespace'::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef DG) Line 160    C++
3414.      liblldb.dll!lldb_private::ASTResultSynthesizer::HandleTopLevelDecl(clang::DeclGroupRef D) Line 109    C++
3415.      liblldb.dll!clang::ParseAST(clang::Sema & S, bool PrintStats, bool SkipFunctionBodies) Line 156    C++
3416.      liblldb.dll!clang::ParseAST(clang::Preprocessor & PP, clang::ASTConsumer * Consumer, clang::ASTContext & Ctx, bool PrintStats, clang::TranslationUnitKind TUKind, clang::CodeCompleteConsumer * CompletionConsumer, bool SkipFunctionBodies) Line 112    C++
3417.      liblldb.dll!lldb_private::ClangExpressionParser::Parse(lldb_private::DiagnosticManager & diagnostic_manager) Line 620    C++
3418.      liblldb.dll!lldb_private::ClangUserExpression::Parse(lldb_private::DiagnosticManager & diagnostic_manager, lldb_private::ExecutionContext & exe_ctx, lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory, bool generate_debug_info) Line 472    C++
3419.      liblldb.dll!lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext & exe_ctx, const lldb_private::EvaluateExpressionOptions & options, llvm::StringRef expr, llvm::StringRef prefix, lldb_private::SharingPtr<lldb_private::ValueObject> & result_valobj_sp, lldb_private::Status & error, unsigned int line_offset, std::basic_string<char,std::char_traits<char>,std::allocator<char> > * fixed_expression, std::shared_ptr<lldb_private::Module> * jit_module_sp_ptr) Line 238    C++
3420.      liblldb.dll!lldb_private::Target::EvaluateExpression(llvm::StringRef expr, lldb_private::ExecutionContextScope * exe_scope, lldb_private::SharingPtr<lldb_private::ValueObject> & result_valobj_sp, const lldb_private::EvaluateExpressionOptions & options, std::basic_string<char,std::char_traits<char>,std::allocator<char> > * fixed_expression) Line 2318    C++
3421.      liblldb.dll!lldb::SBFrame::EvaluateExpression(const char * expr, const lldb::SBExpressionOptions & options) Line 1304    C++
3422.      liblldb.dll!lldb::SBFrame::EvaluateExpression(const char * expr) Line 1215    C++


More information about the lldb-dev mailing list