[PATCH] D64374: [analyzer] CastValueChecker: Model casts

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 9 15:55:24 PDT 2019


Charusso added a comment.

In D64374#1577266 <https://reviews.llvm.org/D64374#1577266>, @NoQ wrote:

> Can you provide more info, eg. the full backtrace?


Well, `unique_dyn_cast<>` and `unique_dyn_cast_or_null<>` is used like 20 times in the LLVM codebase, whoops. We want to model it.

Full info:

  clang++: /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:333: clang::ento::ProgramStateRef clang::ento::ExprEngine::createTemporaryRegionIfNeeded(clang::ento::ProgramStateRef, const clang::LocationContext *, const clang::Expr *, const clang::Expr *, const clang::ento::SubRegion **): Assertion `!InitValWithAdjustments.getAs<Loc>() || Loc::isLocType(Result->getType()) || Result->getType()->isMemberPointerType()' failed.
  Stack dump:
  0.	Program arguments: /home/username/llvm-project/build/bin/clang++ -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -main-file-name PrettyVariableDumper.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir /home/username/llvm-project/build/lib/clang/9.0.0 -D GTEST_HAS_RTTI=0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/llvm-pdbutil -I /home/username/gsoc/llvm-project/llvm/tools/llvm-pdbutil -I /usr/include/libxml2 -I include -I /home/username/gsoc/llvm-project/llvm/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/local/include -internal-isystem /home/username/llvm-project/build/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-noexcept-type -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/username/gsoc/llvm-project/build -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -o /home/username/gsoc/scan-build/llvm-project/2019-07-09-085802-2471-1 -x c++ /home/username/gsoc/llvm-project/llvm/tools/llvm-pdbutil/PrettyVariableDumper.cpp 
  1.	<eof> parser at end of file
  2.	While analyzing stack: 
  	#0 Calling llvm::unique_dyn_cast at line /home/username/gsoc/llvm-project/llvm/include/llvm/Support/Casting.h:397:10
  	#1 Calling llvm::unique_dyn_cast_or_null at line /home/username/gsoc/llvm-project/llvm/include/llvm/Support/Casting.h:403:10
  	#2 Calling llvm::unique_dyn_cast_or_null at line /home/username/gsoc/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:160:12
  	#3 Calling llvm::pdb::PDBSymbol::getConcreteSymbolByIdHelper at line /home/username/gsoc/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbolTypePointer.h:34:3 <Spelling=/home/username/gsoc/llvm-project/llvm/include/llvm/DebugInfo/PDB/PDBSymbol.h:31:12>
  	#4 Calling llvm::pdb::PDBSymbolTypePointer::getPointeeType at line 200
  	#5 Calling llvm::pdb::VariableDumper::dumpRight
  3.	/home/username/gsoc/llvm-project/llvm/include/llvm/Support/Casting.h:381:10: Error evaluating statement
  4.	/home/username/gsoc/llvm-project/llvm/include/llvm/Support/Casting.h:381:10: Error evaluating statement
   #0 0x00007f2daaccc19f llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/username/llvm-project/llvm/lib/Support/Unix/Signals.inc:494:13
   #1 0x00007f2daacca400 llvm::sys::RunSignalHandlers() /home/username/llvm-project/llvm/lib/Support/Signals.cpp:69:18
   #2 0x00007f2daaccc5a8 SignalHandler(int) /home/username/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:1
   #3 0x00007f2daa5c2890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
   #4 0x00007f2da8868e97 raise /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
   #5 0x00007f2da886a801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
   #6 0x00007f2da885a39a __assert_fail_base /build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
   #7 0x00007f2da885a412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
   #8 0x00007f2da410c03e (/home/username/llvm-project/build/bin/../lib/../lib/../lib/libclangStaticAnalyzerCore.so.9svn+0x13303e)
   #9 0x00007f2da4129ad9 llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>::swap(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>&) /home/username/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:169:20
  #10 0x00007f2da4129ad9 llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>::operator=(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) /home/username/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:159:0
  #11 0x00007f2da4129ad9 clang::ento::ExprEngine::CreateCXXTemporaryObject(clang::MaterializeTemporaryExpr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:34:0
  #12 0x00007f2da4110f67 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1709:25
  #13 0x00007f2da410d81e clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:791:9
  #14 0x00007f2da410d4c9 clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:637:7
  #15 0x00007f2da40fee01 clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:469:1
  #16 0x00007f2da40fddbe std::__uniq_ptr_impl<clang::ento::WorkList, std::default_delete<clang::ento::WorkList> >::_M_ptr() const /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/unique_ptr.h:150:42
  #17 0x00007f2da40fddbe std::unique_ptr<clang::ento::WorkList, std::default_delete<clang::ento::WorkList> >::get() const /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/unique_ptr.h:343:0
  #18 0x00007f2da40fddbe std::unique_ptr<clang::ento::WorkList, std::default_delete<clang::ento::WorkList> >::operator->() const /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/unique_ptr.h:337:0
  #19 0x00007f2da40fddbe clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) /home/username/llvm-project/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:129:0
  #20 0x00007f2da48a76aa llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>::release() /home/username/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:188:9
  #21 0x00007f2da48a76aa llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>::~IntrusiveRefCntPtr() /home/username/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:156:0
  #22 0x00007f2da48a76aa clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int) /home/username/llvm-project/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:168:0
  #23 0x00007f2da48a76aa (anonymous namespace)::AnalysisConsumer::RunPathSensitiveChecks(clang::Decl*, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*> >*) /home/username/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:797:0
  #24 0x00007f2da48a76aa (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*> >*) /home/username/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:770:0
  #25 0x00007f2da489f815 llvm::DenseMapBase<llvm::DenseMap<clang::Decl const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<clang::Decl const*>, llvm::detail::DenseSetPair<clang::Decl const*> >, clang::Decl const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<clang::Decl const*>, llvm::detail::DenseSetPair<clang::Decl const*> >::empty() const /home/username/llvm-project/llvm/include/llvm/ADT/DenseMap.h:123:28
  #26 0x00007f2da489f815 llvm::DenseMapBase<llvm::DenseMap<clang::Decl const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<clang::Decl const*>, llvm::detail::DenseSetPair<clang::Decl const*> >, clang::Decl const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<clang::Decl const*>, llvm::detail::DenseSetPair<clang::Decl const*> >::begin() /home/username/llvm-project/llvm/include/llvm/ADT/DenseMap.h:102:0
  #27 0x00007f2da489f815 llvm::detail::DenseSetImpl<clang::Decl const*, llvm::DenseMap<clang::Decl const*, llvm::detail::DenseSetEmpty, llvm::DenseMapInfo<clang::Decl const*>, llvm::detail::DenseSetPair<clang::Decl const*> >, llvm::DenseMapInfo<clang::Decl const*> >::begin() /home/username/llvm-project/llvm/include/llvm/ADT/DenseSet.h:159:0
  #28 0x00007f2da489f815 (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int) /home/username/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:560:0
  #29 0x00007f2da489f815 (anonymous namespace)::AnalysisConsumer::runAnalysisOnTranslationUnit(clang::ASTContext&) /home/username/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:607:0
  #30 0x00007f2da489f815 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) /home/username/llvm-project/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:636:0
  #31 0x00007f2da55ec443 __gnu_cxx::__normal_iterator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >*, std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > > >::__normal_iterator(std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >* const&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_iterator.h:784:20
  #32 0x00007f2da55ec443 std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > >::begin() /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_vector.h:699:0
  #33 0x00007f2da55ec443 void clang::finalize<std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > > >(std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > >&, clang::Sema const&) /home/username/llvm-project/clang/include/clang/Sema/TemplateInstCallback.h:54:0
  #34 0x00007f2da55ec443 clang::ParseAST(clang::Sema&, bool, bool) /home/username/llvm-project/clang/lib/Parse/ParseAST.cpp:178:0
  #35 0x00007f2da98f1061 clang::FrontendAction::Execute() /home/username/llvm-project/clang/lib/Frontend/FrontendAction.cpp:938:10
  #36 0x00007f2da98a70d8 llvm::Error::getPtr() const /home/username/llvm-project/llvm/include/llvm/Support/Error.h:273:42
  #37 0x00007f2da98a70d8 llvm::Error::operator bool() /home/username/llvm-project/llvm/include/llvm/Support/Error.h:236:0
  #38 0x00007f2da98a70d8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/username/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:944:0
  #39 0x00007f2da97d651e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/username/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:291:25
  #40 0x0000000000211def cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/username/llvm-project/clang/tools/driver/cc1_main.cpp:249:15
  #41 0x000000000020fb6b ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/username/llvm-project/clang/tools/driver/driver.cpp:309:12
  #42 0x000000000020fb6b main /home/username/llvm-project/clang/tools/driver/driver.cpp:381:0
  #43 0x00007f2da884bb97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
  #44 0x000000000020d02a _start (/home/username/llvm-project/build/bin/clang+++0x20d02a)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64374/new/

https://reviews.llvm.org/D64374





More information about the cfe-commits mailing list