[LLVMbugs] [Bug 17665] New: Creduce crashes in CFGBuilder::addAutomaticObjDtors

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 23 10:28:38 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17665

            Bug ID: 17665
           Summary: Creduce crashes in CFGBuilder::addAutomaticObjDtors
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: octoploid at yandex.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Creduce crashes quite often when build with current trunk clang.

markus at x4 /tmp % gdb --args /var/tmp/creduce/clang_delta/clang_delta
--query-instances=replace-function-def-with-decl test.ii
Reading symbols from /var/tmp/creduce/clang_delta/clang_delta...done.
(gdb) run
Starting program: /var/tmp/creduce/clang_delta/clang_delta
--query-instances=replace-function-def-with-decl test.ii
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
clang::FunctionDecl::isNoReturn (this=0x0) at
/home/markus/llvm/tools/clang/lib/AST/Decl.cpp:2412
2412      return hasAttr<NoReturnAttr>() || hasAttr<CXX11NoReturnAttr>() ||
(gdb) bt
#0  clang::FunctionDecl::isNoReturn (this=0x0) at
/home/markus/llvm/tools/clang/lib/AST/Decl.cpp:2412
#1  0x0000000000f81099 in (anonymous
namespace)::CFGBuilder::addAutomaticObjDtors (this=0x7fffffffcc50, S=0x1bde4f0,
B=..., E=...)
    at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:854
#2  0x0000000000f815ff in (anonymous
namespace)::CFGBuilder::addLocalScopeAndDtors (this=<optimized out>,
S=<optimized out>)
    at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1028
#3  0x0000000000f85585 in addLocalScopeAndDtors (S=0x1bde4f0,
this=0x7fffffffcc50) at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1572
#4  (anonymous namespace)::CFGBuilder::VisitCompoundStmt
(this=this at entry=0x7fffffffcc50, C=C at entry=0x1bde4f0) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1557
#5  0x0000000000f83f43 in (anonymous namespace)::CFGBuilder::Visit
(this=this at entry=0x7fffffffcc50, S=S at entry=0x1bde4f0, asc=..., asc at entry=...)
    at /home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:1092
#6  0x0000000000f88390 in addStmt (S=0x1bde4f0, this=0x7fffffffcc50) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:434
#7  buildCFG (Statement=0x1bde4f0, D=<optimized out>, this=0x7fffffffcc50) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:660
#8  clang::CFG::buildCFG (D=<optimized out>, Statement=0x1bde4f0,
C=C at entry=0x1737160, BO=...) at
/home/markus/llvm/tools/clang/lib/Analysis/CFG.cpp:3421
#9  0x0000000000f75c47 in clang::AnalysisDeclContext::getCFG
(this=this at entry=0x7fffffffcfe0) at
/home/markus/llvm/tools/clang/lib/Analysis/AnalysisDeclContext.cpp:179
#10 0x0000000000f68804 in CheckFallThrough (AC=...) at
/home/markus/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:102
#11 CheckFallThroughForBody (AC=..., CD=..., blkExpr=<optimized out>,
Body=0x1bde4f0, D=0x1bddce0, S=...)
    at /home/markus/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:359
#12 clang::sema::AnalysisBasedWarnings::IssueWarnings
(this=this at entry=0x17584b8, P=..., fscope=fscope at entry=0x1758f80,
D=D at entry=0x1bddce0, blkExpr=blkExpr at entry=0x0)
    at /home/markus/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:1714
#13 0x0000000000c526d7 in clang::Sema::PopFunctionScopeInfo
(this=this at entry=0x1756c70, WP=WP at entry=0x7fffffffd280, D=D at entry=0x1bddce0,
blkExpr=blkExpr at entry=0x0)
    at /home/markus/llvm/tools/clang/lib/Sema/Sema.cpp:1052
#14 0x0000000000ce131e in clang::Sema::ActOnFinishFunctionBody (this=0x1756c70,
dcl=dcl at entry=0x1bddce0, Body=0x1bde4f0,
IsInstantiation=IsInstantiation at entry=false)
    at /home/markus/llvm/tools/clang/lib/Sema/SemaDecl.cpp:9806
#15 0x0000000000ce1b87 in clang::Sema::ActOnFinishFunctionBody (this=<optimized
out>, D=D at entry=0x1bddce0, BodyArg=<optimized out>)
    at /home/markus/llvm/tools/clang/lib/Sema/SemaDecl.cpp:9654
#16 0x0000000000c2de95 in clang::Parser::ParseFunctionStatementBody
(this=this at entry=0x1771f90, Decl=0x1bddce0, BodyScope=...)
    at /home/markus/llvm/tools/clang/lib/Parse/ParseStmt.cpp:2419
#17 0x0000000000c3b6e4 in clang::Parser::ParseLexedMethodDef (this=0x1771f90,
LM=...) at
/home/markus/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:461
#18 0x0000000000c3b500 in clang::Parser::ParseLexedMethodDefs (this=0x1771f90,
Class=...) at
/home/markus/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp:398
#19 0x0000000000bf3e00 in clang::Parser::ParseCXXMemberSpecification
(this=this at entry=0x1771f90, RecordLoc=..., AttrFixitLoc=...,
AttrFixitLoc at entry=..., Attrs=..., 
    TagType=TagType at entry=18, TagDecl=TagDecl at entry=0x1bdd0b0) at
/home/markus/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:2713
#20 0x0000000000bf585a in clang::Parser::ParseClassSpecifier
(this=this at entry=0x1771f90, TagTokKind=TagTokKind at entry=clang::tok::kw_class,
StartLoc=..., DS=..., 
    TemplateInfo=..., AS=AS at entry=clang::AS_none,
EnteringContext=EnteringContext at entry=true,
DSC=DSC at entry=clang::Parser::DSC_top_level, Attributes=...)
    at /home/markus/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp:1614
#21 0x0000000000bd9555 in clang::Parser::ParseDeclarationSpecifiers
(this=this at entry=0x1771f90, DS=..., TemplateInfo=...,
AS=AS at entry=clang::AS_none, 
    DSContext=DSContext at entry=clang::Parser::DSC_top_level,
LateAttrs=LateAttrs at entry=0x0) at
/home/markus/llvm/tools/clang/lib/Parse/ParseDecl.cpp:3043
#22 0x0000000000bcbdf4 in clang::Parser::ParseDeclOrFunctionDefInternal
(this=this at entry=0x1771f90, attrs=..., DS=..., AS=AS at entry=clang::AS_none)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:852
#23 0x0000000000bcc4f9 in clang::Parser::ParseDeclarationOrFunctionDefinition
(this=0x1771f90, attrs=..., AS=clang::AS_none, DS=0x0)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:918
#24 0x0000000000bcc52f in clang::Parser::ParseDeclarationOrFunctionDefinition
(this=<optimized out>, attrs=..., DS=<optimized out>, AS=<optimized out>)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:920
#25 0x0000000000bd0403 in clang::Parser::ParseExternalDeclaration
(this=this at entry=0x1771f90, attrs=..., DS=DS at entry=0x0)
    at /home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:783
#26 0x0000000000bd0ce2 in clang::Parser::ParseTopLevelDecl
(this=this at entry=0x1771f90, Result=...) at
/home/markus/llvm/tools/clang/lib/Parse/Parser.cpp:588
#27 0x0000000000bc72eb in clang::ParseAST (S=...,
PrintStats=PrintStats at entry=false,
SkipFunctionBodies=SkipFunctionBodies at entry=false)
    at /home/markus/llvm/tools/clang/lib/Parse/ParseAST.cpp:134
#28 0x0000000000a32602 in TransformationManager::doTransformation
(this=0x170d5c0, ErrorMsg="", ErrorCode=@0x167e170: -1) at
TransformationManager.cpp:200
#29 0x000000000046ec34 in main (argc=<optimized out>, argv=<optimized out>) at
ClangDelta.cpp:211
(gdb) q

As you can see dtor is NULL in CFGBuilder::addAutomaticObjDtors
lib/Analysis/CFG.cpp.

The following patch fixes the issue for me:

diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 5b48a15def0e..18931334cdc6 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -851,7 +851,7 @@ void
CFGBuilder::addAutomaticObjDtors(LocalScope::const_iterator B,
     Ty = Context->getBaseElementType(Ty);

     const CXXDestructorDecl *Dtor = Ty->getAsCXXRecordDecl()->getDestructor();
-    if (Dtor->isNoReturn())
+    if (Dtor && Dtor->isNoReturn())
       Block = createNoReturnBlock();
     else
       autoCreateBlock();

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131023/fb41a8d4/attachment.html>


More information about the llvm-bugs mailing list