llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Assertion `ThisRegion && "ThisValue was not a memory region"' failed

Open llvmbot opened this issue 11 years ago • 8 comments

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 struct x1 { typedef x0 x2; }; template <typename x3, typename x4 = x3> struct x5 { public: typename x1::x2 operator {} }; struct x0 { public: template void x6() const; x5 x7; } x8; void x9() { x8.x7[0].x6<x5>(); }

$ 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

llvmbot avatar Nov 03 '15 21:11 llvmbot

mentioned in issue llvm/llvm-bugzilla-archive#25936

devincoughlin avatar Nov 26 '21 21:11 devincoughlin

*** Bug llvm/llvm-bugzilla-archive#25936 has been marked as a duplicate of this bug. ***

devincoughlin avatar Dec 30 '15 03:12 devincoughlin

Fixed by Devin Coughlin in r252506. Verified that the fix works. Thank you!

llvmbot avatar Nov 10 '15 18:11 llvmbot

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

llvmbot avatar Nov 09 '15 17:11 llvmbot

Devin, what's the plan here? Should r250237 be reverted?

llvmbot avatar Nov 08 '15 11:11 llvmbot

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.

llvmbot avatar Nov 04 '15 02:11 llvmbot

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.

devincoughlin avatar Nov 03 '15 22:11 devincoughlin

assigned to @devincoughlin

llvmbot avatar Nov 03 '15 21:11 llvmbot