https://bugs.kde.org/show_bug.cgi?id=389360

            Bug ID: 389360
           Summary: [PATCH] Fix crash in inefficientqlistbase.cpp checking
                    to use QVector instead of QList
           Product: clazy
           Version: unspecified
          Platform: Compiled Sources
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-b...@kde.org
          Reporter: williamba...@hotmail.com
                CC: smart...@kde.org
  Target Milestone: ---

Created attachment 110085
  --> https://bugs.kde.org/attachment.cgi?id=110085&action=edit
proposed patch to fix the problem

I get the crash running the command below:
clazy-standalone -checks=level2 -p build/bear/compile_commands.json
build/bear/DatabaseManager/DatabaseManager_autogen/mocs_compilation.cpp
There are a lot of files that include other files. If necessary, if you tell me
how to track everything down, I could try to gather them up and to find the
command line options.
I have Fedora 27 x86_64. I installed clang-5.0.0-1.fc27.x86_64,
llvm-5.0.0-5.fc27.x86_64, and the corresponding libraries and development
packages. I cloned clazy from git and built it from source linked to Fedora's
clang and llvm.
I have the traceback below, and looking at the code where it crashed and other
similar sections of code, it looked like the problem was that after checking
for !qt2.getTypePtrOrNull(), it also needed to check for
qt2->isIncompleteType(). I put in debug code to show that when it got an
incomplete type, m_astContext.getTypeSize(qt2) crashed.

Program received signal SIGSEGV, Segmentation fault.
clang::ASTContext::getASTRecordLayout (this=this@entry=0x8763c0, D=<optimized
out>, D@entry=0x2f7c5e0)
    at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/AST/RecordLayoutBuilder.cpp:2964
2964        if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
(gdb) bt
#0  clang::ASTContext::getASTRecordLayout (this=this@entry=0x8763c0,
D=<optimized out>, D@entry=0x2f7c5e0)
    at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/AST/RecordLayoutBuilder.cpp:2964
#1  0x00007ffff50a362a in clang::ASTContext::getTypeInfoImpl
(this=this@entry=0x8763c0, T=0x2f7c6e0) at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/AST/ASTContext.cpp:1872
#2  0x00007ffff509b325 in clang::ASTContext::getTypeInfo (this=0x8763c0,
T=<optimized out>) at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/AST/ASTContext.cpp:1612
#3  0x00007ffff761d0de in clang::ASTContext::getTypeInfo (this=0x8763c0, T=...)
at /usr/include/clang/AST/ASTContext.h:1918
#4  0x00007ffff761d103 in clang::ASTContext::getTypeSize (this=0x8763c0, T=...)
at /usr/include/clang/AST/ASTContext.h:1924
#5  0x00007ffff763e077 in InefficientQListBase::VisitDecl (this=0x885320,
decl=0x2f7c9a8) at /u/u3/gnu/clazy/src/checks/inefficientqlistbase.cpp:99
#6  0x00007ffff76691a0 in ClazyASTConsumer::VisitDecl (this=0x860850,
decl=0x2f7c9a8) at /u/u3/gnu/clazy/src/Clazy.cpp:104
#7  0x00007ffff769c762 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromDecl (this=0x860850,
D=0x2f7c9a8) at /usr/include/clang/AST/RecursiveASTVisitor.h:483
#8  0x00007ffff76a6b4a in
clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromNamedDecl
(this=0x860850, D=0x2f7c9a8) at /usr/include/clang/AST/DeclNodes.inc:95
#9  0x00007ffff76aae5a in
clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromValueDecl
(this=0x860850, D=0x2f7c9a8) at /usr/include/clang/AST/DeclNodes.inc:355
#10 0x00007ffff76aaf42 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromDeclaratorDecl
(this=0x860850, D=0x2f7c9a8) at /usr/include/clang/AST/DeclNodes.inc:365
#11 0x00007ffff768ec52 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromVarDecl (this=0x860850,
D=0x2f7c9a8) at /usr/include/clang/AST/DeclNodes.inc:441
#12 0x00007ffff768efa6 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::WalkUpFromParmVarDecl
(this=0x860850, D=0x2f7c9a8) at /usr/include/clang/AST/DeclNodes.inc:463
#13 0x00007ffff7683ee6 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseParmVarDecl
(this=0x860850, D=0x2f7c9a8) at
/usr/include/clang/AST/RecursiveASTVisitor.h:2026
#14 0x00007ffff767a82c in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl (this=0x860850,
D=0x2f7c9a8) at /usr/include/clang/AST/DeclNodes.inc:463
#15 0x00007ffff769e33a in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseFunctionProtoTypeLoc
(this=0x860850, TL=...)
    at /usr/include/clang/AST/RecursiveASTVisitor.h:1214
#16 0x00007ffff768a7c5 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseTypeLoc (this=0x860850,
TL=...) at /usr/include/clang/AST/TypeNodes.def:79
#17 0x00007ffff768e5b6 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseFunctionHelper
(this=0x860850, D=0x2f7ce60) at
/usr/include/clang/AST/RecursiveASTVisitor.h:1937
#18 0x00007ffff7683364 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseCXXConstructorDecl
(this=0x860850, D=0x2f7ce60)
    at /usr/include/clang/AST/RecursiveASTVisitor.h:1982
#19 0x00007ffff767a661 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl (this=0x860850,
D=0x2f7ce60) at /usr/include/clang/AST/DeclNodes.inc:403
#20 0x00007ffff768a351 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDeclContextHelper
(this=0x860850, DC=0x2f7b2d8)
    at /usr/include/clang/AST/RecursiveASTVisitor.h:1350
#21 0x00007ffff7681788 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseCXXRecordDecl
(this=0x860850, D=0x2f7b2a0) at
/usr/include/clang/AST/RecursiveASTVisitor.h:1787
#22 0x00007ffff767a265 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl (this=0x860850,
D=0x2f7b2a0) at /usr/include/clang/AST/DeclNodes.inc:251
#23 0x00007ffff768a351 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDeclContextHelper
(this=0x860850, DC=0x87be90)
    at /usr/include/clang/AST/RecursiveASTVisitor.h:1350
#24 0x00007ffff7685093 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseTranslationUnitDecl
(this=0x860850, D=0x87be70)
    at /usr/include/clang/AST/RecursiveASTVisitor.h:1442
#25 0x00007ffff767aa90 in
clang::RecursiveASTVisitor<ClazyASTConsumer>::TraverseDecl (this=0x860850,
D=0x87be70) at /usr/include/clang/AST/DeclNodes.inc:553
#26 0x00007ffff76694ad in ClazyASTConsumer::HandleTranslationUnit
(this=0x860850, ctx=...) at /u/u3/gnu/clazy/src/Clazy.cpp:153
#27 0x00007ffff6fe18d8 in clang::MultiplexConsumer::HandleTranslationUnit
(this=<optimized out>, Ctx=...)
    at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/Frontend/MultiplexConsumer.cpp:305
#28 0x00007ffff4a81ce9 in clang::ParseAST (S=..., PrintStats=<optimized out>,
SkipFunctionBodies=<optimized out>)
    at /usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/Parse/ParseAST.cpp:159
#29 0x00007ffff6fb3256 in clang::FrontendAction::Execute
(this=this@entry=0x861120) at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/Frontend/FrontendAction.cpp:902
#30 0x00007ffff6f715ba in clang::CompilerInstance::ExecuteAction
(this=this@entry=0x7fffffffa730, Act=...)
    at
/usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/Frontend/CompilerInstance.cpp:980
#31 0x00007ffff34b4a00 in clang::tooling::FrontendActionFactory::runInvocation
(this=0x79d2a0, Invocation=..., Files=0x72f670, PCHContainerOps=...,
DiagConsumer=0x0)
    at /usr/src/debug/clang-5.0.0-1.fc27.x86_64/lib/Tooling/Tooling.cpp:321

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to