Ericsson / clang

Cross Translation Unit analysis capability for Clang Static Analyzer. (Fork of official clang at http://llvm.org/git/clang)
http://clang.llvm.org/
Other
15 stars 10 forks source link

Assertion `Result && "Could not evaluate expression"` failed #473

Closed martong closed 6 years ago

martong commented 6 years ago
#0  0x00007ffff0c82428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff0c8402a in __GI_abort () at abort.c:89
#2  0x00007ffff0c7abd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x7fffee0d1cac "Result && \"Could not evaluate expression\"", file=file@entry=0x7fffee0d1cd6 "../../git/llvm/tools/clang/lib/AST/ExprConstant.cpp", line=line@entry=10185, function=function@entry=0x7fffee0d1d0a "llvm::APSInt clang::Expr::EvaluateKnownConstInt(const clang::ASTContext &, SmallVectorImpl<PartialDiagnosticAt> *) const") at assert.c:92
#3  0x00007ffff0c7ac82 in __GI___assert_fail (assertion=0x7fffee0d1cac "Result && \"Could not evaluate expression\"", file=0x7fffee0d1cd6 "../../git/llvm/tools/clang/lib/AST/ExprConstant.cpp", line=10185, function=0x7fffee0d1d0a "llvm::APSInt clang::Expr::EvaluateKnownConstInt(const clang::ASTContext &, SmallVectorImpl<PartialDiagnosticAt> *) const") at assert.c:101
#4  0x00007fffedf13a04 in clang::Expr::EvaluateKnownConstInt(clang::ASTContext const&, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >*) const () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/libclangAST.so.6
#5  0x00007fffe9e41969 in clang::ento::ExprEngine::processSwitch(clang::ento::SwitchNodeBuilder&) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.6
#6  0x00007fffe9e29b27 in clang::ento::CoreEngine::HandleBlockExit(clang::CFGBlock const*, clang::ento::ExplodedNode*) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.6
#7  0x00007fffe9e289c9 in clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.6
#8  0x00007fffeb11e187 in (anonymous namespace)::AnalysisConsumer::ActionExprEngine(clang::Decl*, bool, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*> >*) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/libclangStaticAnalyzerFrontend.so.6
#9  0x00007fffeb11dd2b in (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*> >*) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/libclangStaticAnalyzerFrontend.so.6
#10 0x00007fffeb116920 in (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/libclangStaticAnalyzerFrontend.so.6
#11 0x00007fffec8f3236 in clang::ParseAST(clang::Sema&, bool, bool) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/../lib/libclangParse.so.6
#12 0x00007ffff1b8b9c8 in clang::FrontendAction::Execute() () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/libclangFrontend.so.6
#13 0x00007ffff1b45f51 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/libclangFrontend.so.6
#14 0x00007ffff18c2850 in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) () from /home/egbomrt/WORK/llvm2/build/release_assert/bin/../lib/libclangFrontendTool.so.6
#15 0x000000000040e88b in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) ()
#16 0x000000000040cb02 in main ()

Occurs in protobuf CTU.

martong commented 6 years ago
#0  0x00007fffedf52428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007fffedf5402a in __GI_abort () at abort.c:89
#2  0x00007fffedf4abd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x7fffea96c9d0 "Result && \"Could not evaluate expression\"", file=file@entry=0x7fffea96c9fa "../../git/llvm/tools/clang/lib/AST/ExprConstant.cpp", line=line@entry=10185, function=function@entry=0x7fffea96ca2e "llvm::APSInt clang::Expr::EvaluateKnownConstInt(const clang::ASTContext &, SmallVectorImpl<PartialDiagnosticAt> *) const") at assert.c:92
#3  0x00007fffedf4ac82 in __GI___assert_fail (assertion=0x7fffea96c9d0 "Result && \"Could not evaluate expression\"", file=0x7fffea96c9fa "../../git/llvm/tools/clang/lib/AST/ExprConstant.cpp", line=10185, function=0x7fffea96ca2e "llvm::APSInt clang::Expr::EvaluateKnownConstInt(const clang::ASTContext &, SmallVectorImpl<PartialDiagnosticAt> *) const") at assert.c:101
#4  0x00007fffea675f7b in clang::Expr::EvaluateKnownConstInt (this=0x281a1d0, Ctx=..., Diag=0x0) at ../../git/llvm/tools/clang/lib/AST/ExprConstant.cpp:10185
#5  0x00007fffe3862ab8 in clang::ento::ExprEngine::processSwitch (this=0x7fffffff7210, builder=...) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:2134
#6  0x00007fffe383b206 in clang::ento::CoreEngine::HandleBlockExit (this=0x7fffffff7230, B=0x9b37cc0, Pred=0x8bc5000) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:465
#7  0x00007fffe383aa9e in clang::ento::CoreEngine::HandlePostStmt (this=0x7fffffff7230, B=0x9b37cc0, StmtIdx=7, Pred=0x8bc5000) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:528
#8  0x00007fffe383a406 in clang::ento::CoreEngine::dispatchWorkItem (this=0x7fffffff7230, Pred=0x8bc5000, Loc=..., WU=...) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:279
#9  0x00007fffe3839f68 in clang::ento::CoreEngine::ExecuteWorkList (this=0x7fffffff7230, L=0x5192ea0, Steps=224766, InitState=...) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:235
#10 0x00007fffe5553925 in clang::ento::ExprEngine::ExecuteWorkList (this=0x7fffffff7210, L=0x5192ea0, Steps=225000) at ../../git/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:114
#11 0x00007fffe54f41eb in (anonymous namespace)::AnalysisConsumer::ActionExprEngine (this=0x6b3210, D=0x22d8110, ObjCGCEnabled=false, IMode=clang::ento::ExprEngine::Inline_Regular, VisitedCallees=0x7fffffff78c8) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:720
#12 0x00007fffe54f3f81 in (anonymous namespace)::AnalysisConsumer::RunPathSensitiveChecks (this=0x6b3210, D=0x22d8110, IMode=clang::ento::ExprEngine::Inline_Regular, Visited=0x7fffffff78c8) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:741
#13 0x00007fffe54f3c35 in (anonymous namespace)::AnalysisConsumer::HandleCode (this=0x6b3210, D=0x22d8110, Mode=2, IMode=clang::ento::ExprEngine::Inline_Regular, VisitedCallees=0x7fffffff78c8) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:687
#14 0x00007fffe54e723e in (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph (this=0x6b3210, LocalTUDeclsSize=1701) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:500
#15 0x00007fffe54e54ad in (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit (this=0x6b3210, C=...) at ../../git/llvm/tools/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:552
#16 0x00007fffe8705de6 in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=false) at ../../git/llvm/tools/clang/lib/Parse/ParseAST.cpp:159
#17 0x00007fffef06829c in clang::ASTFrontendAction::ExecuteAction (this=0x692310) at ../../git/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:998
#18 0x00007fffef067d10 in clang::FrontendAction::Execute (this=0x692310) at ../../git/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:897
#19 0x00007fffeefdcf1a in clang::CompilerInstance::ExecuteAction (this=0x6712e0, Act=...) at ../../git/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:991
#20 0x00007fffeeba3ce6 in clang::ExecuteCompilerInvocation (Clang=0x6712e0) at ../../git/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:252
#21 0x0000000000425649 in cc1_main (Argv=llvm::ArrayRef of length 315 = {...}, Argv0=0x7fffffffb735 "/home/egbomrt/WORK/llvm2/build/debug/bin/clang-6.0", MainAddr=0x415d70 <GetExecutablePath[abi:cxx11](char const*, bool)>) at ../../git/llvm/tools/clang/tools/driver/cc1_main.cpp:221
#22 0x0000000000418189 in ExecuteCC1Tool (argv=llvm::ArrayRef of length 317 = {...}, Tool="") at ../../git/llvm/tools/clang/tools/driver/driver.cpp:309
#23 0x0000000000416e8d in main (argc_=317, argv_=0x7fffffffa8d8) at ../../git/llvm/tools/clang/tools/driver/driver.cpp:388
martong commented 6 years ago

The init expression of a VarDecl is overwritten in the "To" context if we import a VarDecl without an init expression (and with a definition). This causes that the constant expression evaluation logic (clang::Expr::EvaluateKnownConstInt) asserts, because it searches for the missing initializer. Related: #477