Assertion `ThisRegion && "ThisValue was not a memory region"' failed
| Bugzilla Link | 25392 |
| Resolution | FIXED |
| Resolved on | Dec 29, 2015 19:29 |
| Version | trunk |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @devincoughlin,@AnnaZaks |
Extended Description
We've started seeing assertion failures in all static analyzer checks on a large number of translation units in our code base. This started happening somewhere after r246545.
Here's a repro:
$ cat sa1.cc
struct x0;
template
$ clang-tidy -checks=-*,clang-analyzer-unix.API sa1.cc -- -std=c++11 llvm/tools/clang/lib/StaticAnalyzer/Core/CallEvent.cpp:441: virtual void clang::ento::CXXInstanceCall::getExtraInvalidatedValues(ValueList &, clang::ento::RegionAndSymbolInvalidationTraits *) const: Assertion `ThisRegion && "ThisValue was not a memory region"' failed. Aborted (core dumped)
Here's the relevant stack trace: *** SIGSEGV (@0x10), see go/cppdebug received by PID 23704 (TID 23704); stack trace: *** PC: @ 0x135f0f4 (unknown) clang::ento::MemRegion::getBaseRegion() @ 0x19f120d 928 FailureSignalHandler() @ 0x7fa928aa9390 1488 __restore_rt @ 0x1380c7f 448 clang::ento::CallEvent::invalidateRegions() @ 0x13ab23e 144 clang::ento::ExprEngine::conservativeEvalCall() @ 0x13abde8 144 clang::ento::ExprEngine::defaultEvalCall() @ 0x139d49d 352 clang::ento::CheckerManager::runCheckersForEvalCall() @ 0x13aaf8a 368 clang::ento::ExprEngine::evalCall() @ 0x13aac77 384 clang::ento::ExprEngine::VisitCallExpr() @ 0x1389b18 1248 clang::ento::ExprEngine::Visit() @ 0x1386257 400 clang::ento::ExprEngine::ProcessStmt() @ 0x1385eec 96 clang::ento::ExprEngine::processCFGElement() @ 0x139727e 160 clang::ento::CoreEngine::dispatchWorkItem() @ 0x1396e7a 192 clang::ento::CoreEngine::ExecuteWorkList() @ 0xb41d82 1120 (anonymous namespace)::AnalysisConsumer::ActionExprEngine() @ 0xb41891 288 (anonymous namespace)::AnalysisConsumer::HandleCode() @ 0xb34c54 480 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit() @ 0xd31a9c 48 clang::MultiplexConsumer::HandleTranslationUnit() @ 0xe3d832 144 clang::ParseAST() @ 0xd4988f 48 clang::FrontendAction::Execute() @ 0xc7a542 96 clang::CompilerInstance::ExecuteAction() @ 0xc332b5 352 clang::tooling::FrontendActionFactory::runInvocation() @ 0xc330fe 64 clang::tooling::ToolInvocation::runInvocation() @ 0xc32c0a 1440 clang::tooling::ToolInvocation::run() @ 0xc341aa 1040 clang::tooling::ClangTool::run() @ 0xa17f65 1952 clang::tidy::runClangTidy() @ 0x435b20 1344 main @ 0x7fa9284fcce8 208 __libc_start_main @ 0x434af9 (unknown) _start
mentioned in issue llvm/llvm-bugzilla-archive#25936
*** Bug llvm/llvm-bugzilla-archive#25936 has been marked as a duplicate of this bug. ***
Fixed by Devin Coughlin in r252506. Verified that the fix works. Thank you!
Sorry for the late response, I've been away.
The function 'getCXXThisVal()' can return an Unknown SVal, which is not a memory region. The code added in r250237 does not check for this case, causing the assertion.
I have uploaded a patch for review which fixes the assert in the reproducible.
Regards, Sean Eveson SN Systems - Sony Computer Entertainment Group
Devin, what's the plan here? Should r250237 be reverted?
Looks like this was introduced in r250237 ([Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)).
The assertion fires when ThisVal in CXXInstanceCall::getExtraInvalidatedValues() is Unknown.
The problem has appeared between r250153 and r250289, so it well may be r250237.
Looks like this was introduced in r250237 ([Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)).
The assertion fires when ThisVal in CXXInstanceCall::getExtraInvalidatedValues() is Unknown.
assigned to @devincoughlin