Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analyzer fires assert with implicit moves in blocks in C mode #51184

Closed
mizvekov opened this issue Sep 14, 2021 · 3 comments
Closed

analyzer fires assert with implicit moves in blocks in C mode #51184

mizvekov opened this issue Sep 14, 2021 · 3 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla clang:static analyzer

Comments

@mizvekov
Copy link
Contributor

Bugzilla Link 51842
Resolution FIXED
Resolved on Sep 17, 2021 10:16
Version trunk
OS Windows NT
Blocks #50580
CC @devincoughlin,@haoNoQ
Fixed by commit(s) 2d6829b 89f2c0c

Extended Description

Crashes when analyzing this program, with runtime checks enabled:

typedef struct {
  int x;
} S;

void foo() {
  ^{
    S s;
    return s;
  };
}

With: clang -cc1 -analyze -w -analyzer-checker=core -fblocks.

Backtrace:

Assertion failed: !location.getAs<NonLoc>() && "location cannot be a NonLoc.", file ..\..\clang\lib\StaticAnalyzer\Core\ExprEngine.cpp, line 2967
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: build\\dbg\\llvm\\bin\\clang.exe -cc1 -analyze -w -analyzer-checker=core -fblocks -verify ..\\..\\clang\\test\\Analysis\\blocks-nrvo.c
1.      <eof> parser at end of file
2.      While analyzing stack:
        #&#8203;0 Calling anonymous code
3.      ..\..\clang\test\Analysis\blocks-nrvo.c:12:12: Error evaluating statement
4.      ..\..\clang\test\Analysis\blocks-nrvo.c:12:12: Error evaluating statement
PS build\dbg> .\llvm\bin\clang.exe -cc1 -analyze -w -analyzer-checker=core -fblocks -verify ..\..\clang\test\Analysis\blocks-nrvo.c
Assertion failed: !location.getAs<NonLoc>() && "location cannot be a NonLoc.", file ..\..\clang\lib\StaticAnalyzer\Core\ExprEngine.cpp, line 2967
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: build\\dbg\\llvm\\bin\\clang.exe -cc1 -analyze -w -analyzer-checker=core -fblocks -verify ..\\..\\clang\\test\\Analysis\\blocks-nrvo.c
1.      <eof> parser at end of file
2.      While analyzing stack:


        #&#8203;0 Calling anonymous code
3.      ..\..\clang\test\Analysis\blocks-nrvo.c:12:12: Error evaluating statement
4.      ..\..\clang\test\Analysis\blocks-nrvo.c:12:12: Error evaluating statement
 #&#8203;0 0x00007ff7d03dd94c HandleAbort llvm\lib\Support\Windows\Signals.inc:408:0
 #&#8203;1 0x00007ffa1179bc31 (C:\Windows\SYSTEM32\ucrtbased.dll+0x6bc31)
 #&#8203;2 0x00007ffa1179d889 (C:\Windows\SYSTEM32\ucrtbased.dll+0x6d889)
 #&#8203;3 0x00007ffa117a34b5 (C:\Windows\SYSTEM32\ucrtbased.dll+0x734b5)
 #&#8203;4 0x00007ffa117a3027 (C:\Windows\SYSTEM32\ucrtbased.dll+0x73027)
 #&#8203;5 0x00007ffa117a1091 (C:\Windows\SYSTEM32\ucrtbased.dll+0x71091)
 #&#8203;6 0x00007ffa117a3a1f (C:\Windows\SYSTEM32\ucrtbased.dll+0x73a1f)
 #&#8203;7 0x00007ff7d496fae2 clang::ento::ExprEngine::evalLoad(class clang::ento::ExplodedNodeSet &, class clang::Expr const *, class clang::Expr const *, class clang::ento::ExplodedNode *, class llvm::IntrusiveRefCntPtr<class clang::ento::ProgramState const>, class clang::ento::SVal, class clang::ProgramPointTag const *, class clang::QualType) clang\lib\StaticAnalyzer\Core\ExprEngine.cpp:2967:0
 #&#8203;8 0x00007ff7d4a7ba55 clang::ento::ExprEngine::VisitCast(class clang::CastExpr const *, class clang::Expr const *, class clang::ento::ExplodedNode *, class clang::ento::ExplodedNodeSet &) clang\lib\StaticAnalyzer\Core\ExprEngineC.cpp:299:0
 #&#8203;9 0x00007ff7d496a76f clang::ento::ExprEngine::Visit(class clang::Stmt const *, class clang::ento::ExplodedNode *, class clang::ento::ExplodedNodeSet &) clang\lib\StaticAnalyzer\Core\ExprEngine.cpp:1739:0
#&#8203;10 0x00007ff7d4963b0f clang::ento::ExprEngine::ProcessStmt(class clang::Stmt const *, class clang::ento::ExplodedNode *) clang\lib\StaticAnalyzer\Core\ExprEngine.cpp:792:0
#&#8203;11 0x00007ff7d496376b clang::ento::ExprEngine::processCFGElement(class clang::CFGElement, class clang::ento::ExplodedNode *, unsigned int, struct clang::ento::NodeBuilderContext *) clang\lib\StaticAnalyzer\Core\ExprEngine.cpp:638:0
#&#8203;12 0x00007ff7d49589e1 clang::ento::CoreEngine::HandlePostStmt(class clang::CFGBlock const *, unsigned int, class clang::ento::ExplodedNode *) clang\lib\StaticAnalyzer\Core\CoreEngine.cpp:470:0
#&#8203;13 0x00007ff7d4959c05 clang::ento::CoreEngine::dispatchWorkItem(class clang::ento::ExplodedNode *, class clang::ProgramPoint, class clang::ento::WorkListUnit const &) clang\lib\StaticAnalyzer\Core\CoreEngine.cpp:194:0
#&#8203;14 0x00007ff7d4959707 clang::ento::CoreEngine::ExecuteWorkList(class clang::LocationContext const *, unsigned int, class llvm::IntrusiveRefCntPtr<class clang::ento::ProgramState const>) clang\lib\StaticAnalyzer\Core\CoreEngine.cpp:148:0
#&#8203;15 0x00007ff7d3bdd745 clang::ento::ExprEngine::ExecuteWorkList(class clang::LocationContext const *, unsigned int) clang\include\clang\StaticAnalyzer\Core\PathSensitive\ExprEngine.h:193:0
#&#8203;16 0x00007ff7d3bc2a29 `anonymous namespace'::AnalysisConsumer::RunPathSensitiveChecks clang\lib\StaticAnalyzer\Frontend\AnalysisConsumer.cpp:680:0
#&#8203;17 0x00007ff7d3bc27da `anonymous namespace'::AnalysisConsumer::HandleCode clang\lib\StaticAnalyzer\Frontend\AnalysisConsumer.cpp:649:0
#&#8203;18 0x00007ff7d3bc2304 `anonymous namespace'::AnalysisConsumer::HandleDeclsCallGraph clang\lib\StaticAnalyzer\Frontend\AnalysisConsumer.cpp:487:0
#&#8203;19 0x00007ff7d3bc387f `anonymous namespace'::AnalysisConsumer::runAnalysisOnTranslationUnit clang\lib\StaticAnalyzer\Frontend\AnalysisConsumer.cpp:537:0
#&#8203;20 0x00007ff7d3bc1f9c `anonymous namespace'::AnalysisConsumer::HandleTranslationUnit clang\lib\StaticAnalyzer\Frontend\AnalysisConsumer.cpp:568:0
#&#8203;21 0x00007ff7d4abe1b8 clang::ParseAST(class clang::Sema &, bool, bool) clang\lib\Parse\ParseAST.cpp:178:0
#&#8203;22 0x00007ff7d18f8ab7 clang::ASTFrontendAction::ExecuteAction(void) clang\lib\Frontend\FrontendAction.cpp:1060:0
#&#8203;23 0x00007ff7d18f846e clang::FrontendAction::Execute(void) clang\lib\Frontend\FrontendAction.cpp:955:0
#&#8203;24 0x00007ff7d1878fd6 clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) clang\lib\Frontend\CompilerInstance.cpp:974:0
#&#8203;25 0x00007ff7d1ae21a7 clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:278:0
#&#8203;26 0x00007ff7cdc0d294 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) clang\tools\driver\cc1_main.cpp:246:0
#&#8203;27 0x00007ff7cdbf8ed0 ExecuteCC1Tool clang\tools\driver\driver.cpp:317:0
#&#8203;28 0x00007ff7cdbf976c main clang\tools\driver\driver.cpp:388:0
#&#8203;29 0x00007ff7d7681559 invoke_main d:\a01\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#&#8203;30 0x00007ff7d76813fe __scrt_common_main_seh d:\a01\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#&#8203;31 0x00007ff7d76812be __scrt_common_main d:\a01\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#&#8203;32 0x00007ff7d76815ee mainCRTStartup d:\a01\_work\3\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
@mizvekov
Copy link
Contributor Author

assigned to @devincoughlin

@haoNoQ
Copy link
Collaborator

haoNoQ commented Sep 14, 2021

Thanks a lot for release-managing this :)

@tstellar
Copy link
Collaborator

Merged: 89f2c0c

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:static analyzer
Projects
None yet
Development

No branches or pull requests

3 participants