Bug 389006 - Asserts are triggered in debug build
Summary: Asserts are triggered in debug build
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-15 13:56 UTC by ivan.donchevskii
Modified: 2018-01-16 19:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Patch that fixes asserts by adding extra checks (3.40 KB, patch)
2018-01-16 07:38 UTC, ivan.donchevskii
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ivan.donchevskii 2018-01-15 13:56:30 UTC
In a debug build I get an assert from clang/lib/Basic/SourceManager.cpp 'SrcMgr::CharacteristicKind SourceManager::getFileCharacteristic(SourceLocation Loc) const' that the location is invalid.
It is called by 'bool ClazyASTConsumer::VisitDecl(Decl *decl)' during isInSystemHeader check.
That probably means that location start is not a valid location.
I get it when I switch from level1 to level2 and open texteditor.cpp from qtcreator sources.

I can provide more info if required.
Comment 1 Sergio Martins 2018-01-15 14:16:23 UTC
Can you check if the location really is invalid ?

and add an if() protecting it, in that case ?
Comment 2 ivan.donchevskii 2018-01-15 15:00:31 UTC
I actually have more of them and I'm not sure if they are actually valid only for level2.

For example, another trace (which can be also fixed with location check):

1  HandleAbort                                                                                    Signals.inc              405  0x7ff95a5490cc 
2  raise                                                                                          ucrtbased                     0x7ff980ed8201 
3  abort                                                                                          ucrtbased                     0x7ff980ed9d89 
4  get_wide_winmain_command_line                                                                  ucrtbased                     0x7ff980edf46f 
5  get_wide_winmain_command_line                                                                  ucrtbased                     0x7ff980edd461 
6  wassert                                                                                        ucrtbased                     0x7ff980edfc6f 
7  clang::SourceManager::getFileCharacteristic                                                    SourceManager.cpp        1385 0x7ff9565d894f 
8  clang::SourceManager::isInSystemHeader                                                         SourceManager.h          1375 0x7ff955e9ec60 
9  ClazyASTConsumer::VisitStmt                                                                    Clazy.cpp                114  0x7ff95866ac42 
10 clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromStmt                                   RecursiveASTVisitor.h    354  0x7ff9586e253a 
11 clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromExpr                                   StmtNodes.inc            115  0x7ff9586d99ee 
12 clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromCXXDefaultArgExpr                      StmtNodes.inc            227  0x7ff9586d569e 
13 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseCXXDefaultArgExpr                        RecursiveASTVisitor.h    2407 0x7ff9586866a9 
14 clang::RecursiveASTVisitor<ClazyASTConsumer>::dataTraverseNode                                 StmtNodes.inc            227  0x7ff9586eb690 
15 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseStmt                                     RecursiveASTVisitor.h    644  0x7ff9586bce31 
16 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseFunctionHelper                           RecursiveASTVisitor.h    1956 0x7ff95869a25e 
17 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseCXXMethodDecl                            RecursiveASTVisitor.h    1975 0x7ff958688bcd 
18 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl                                     DeclNodes.inc            399  0x7ff9586922af 
19 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDeclContextHelper                        RecursiveASTVisitor.h    1350 0x7ff958692e5b 
20 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseCXXRecordDecl                            RecursiveASTVisitor.h    1787 0x7ff958689e87 
21 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl                                     DeclNodes.inc            251  0x7ff958691ed3 
22 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseClassTemplateDecl                        RecursiveASTVisitor.h    1695 0x7ff95868db66 
23 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl                                     DeclNodes.inc            195  0x7ff958691d67 
24 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDeclContextHelper                        RecursiveASTVisitor.h    1350 0x7ff958692e5b 
25 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseNamespaceDecl                            RecursiveASTVisitor.h    1466 0x7ff9586a2b78 
26 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl                                     DeclNodes.inc            105  0x7ff958691b2b 
27 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDeclContextHelper                        RecursiveASTVisitor.h    1350 0x7ff958692e5b 
28 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseTranslationUnitDecl                      RecursiveASTVisitor.h    1442 0x7ff9586c09b8 
29 clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl                                     DeclNodes.inc            553  0x7ff958692721 
30 ClazyASTConsumer::HandleTranslationUnit                                                        Clazy.cpp                157  0x7ff95866af1b 
31 clang::MultiplexConsumer::HandleTranslationUnit                                                MultiplexConsumer.cpp    305  0x7ff956742c59 
32 clang::ParseAST                                                                                ParseAST.cpp             161  0x7ff95b2ba561 
33 clang::ASTFrontendAction::ExecuteAction                                                        FrontendAction.cpp       1005 0x7ff95671dceb 
34 clang::FrontendAction::Execute                                                                 FrontendAction.cpp       906  0x7ff95671d747 
35 clang::ASTUnit::Parse                                                                          ASTUnit.cpp              1118 0x7ff95662aec1 
36 clang::ASTUnit::LoadFromCompilerInvocation                                                     ASTUnit.cpp              1585 0x7ff95662fceb 
37 clang::ASTUnit::LoadFromCommandLine                                                            ASTUnit.cpp              1706 0x7ff956631df2 
38 clang_parseTranslationUnit_Impl                                                                CIndex.cpp               3425 0x7ff955d94de6 
39 <lambda_b7549923c4878d05b8a2ab66ef5254b1>::operator()                                          CIndex.cpp               3501 0x7ff955ddcba7 
40 llvm::function_ref<void __cdecl(void)>::callback_fn<<lambda_b7549923c4878d05b8a2ab66ef5254b1>> STLExtras.h              100  0x7ff955db42c8 
41 llvm::function_ref<void __cdecl(void)>::operator()                                             STLExtras.h              114  0x7ff95a5464de 
42 llvm::CrashRecoveryContext::RunSafely                                                          CrashRecoveryContext.cpp 183  0x7ff95a545d6b 
43 RunSafelyOnThread_Dispatch                                                                     CrashRecoveryContext.cpp 402  0x7ff95a545fa2 
44 ThreadCallback                                                                                 Threading.inc            36   0x7ff95a5449c8 
45 register_onexit_function                                                                       ucrtbased                     0x7ff980ee11e8 
46 register_onexit_function                                                                       ucrtbased                     0x7ff980ee0e01 
47 BaseThreadInitThunk                                                                            KERNEL32                      0x7ff9b36e1fe4 
48 RtlUserThreadStart                                                                             ntdll                         0x7ff9b5d9ef91 

The next one is "Assertion failed: Loc.isMacroID() && "Only reasonble to call this on macros", file D:\code\llvm\tools\clang\lib\Lex\Lexer.cpp, line 962"
Comment 3 Sergio Martins 2018-01-15 18:02:37 UTC
Is this only when switching to level2, or also happens when QtCreator is started with level2 already selected ?
Comment 4 ivan.donchevskii 2018-01-16 07:16:30 UTC
I've rechecked. The initial assert happens even with level0. Another one with Loc.isMacroID() happens only starting with level1
Comment 5 ivan.donchevskii 2018-01-16 07:38:32 UTC
Created attachment 109902 [details]
Patch that fixes asserts by adding extra checks

I've added extra checks which prevent described assets.
Comment 6 Sergio Martins 2018-01-16 19:08:53 UTC
Git commit a69e0de68409ac237db86e746b873e3763c33239 by Sergio Martins, on behalf of Ivan Donchevskii.
Committed on 16/01/2018 at 19:07.
Pushed by smartins into branch 'master'.

Fix asserts when in debug mode

M  +6    -4    src/Clazy.cpp
M  +6    -3    src/checks/level1/non-pod-global-static.cpp
M  +2    -0    src/checks/level2/implicitcasts.cpp

https://commits.kde.org/clazy/a69e0de68409ac237db86e746b873e3763c33239