Open Quuxplusone opened 6 years ago
Attached VMMapsMain-263a78.zip
(476221 bytes, application/zip): clang front end failed while compiling android NDK project
This reproduces with trunk r327300. I'm minimizing the test case.
Minimized test case:
// clang -cc1 -triple x86_64 -S VMMapsMain-minimized.cpp
class a {
protected:
~a();
};
class b : a {};
class c;
class d {
c *e;
virtual ~d() { delete e; }
};
class c {
b f;
};
void g() { new d; }
I tried bisecting, but the oldest version of clang that I have lying around is
trunk r188068 (from 2013!) and it also segfaults in the same manner.
Crash backtrace:
Program received signal SIGSEGV, Segmentation fault.
clang::CXXMethodDecl::isVirtual (this=0x0) at
/home/dim/src/llvm/trunk/tools/clang/include/clang/AST/DeclCXX.h:2065
2065 CXXMethodDecl *CD = const_cast<CXXMethodDecl*>(this)-
>getCanonicalDecl();
(gdb) bt
#0 clang::CXXMethodDecl::isVirtual (this=0x0) at
/home/dim/src/llvm/trunk/tools/clang/include/clang/AST/DeclCXX.h:2065
#1 0x0000000004d17791 in EmitObjectDelete (CGF=..., DE=0x808895150, Ptr=...,
ElementType=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExprCXX.cpp:1865
#2 0x0000000004d1713d in clang::CodeGen::CodeGenFunction::EmitCXXDeleteExpr
(this=0x7fffffff40f0, E=0x808895150) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExprCXX.cpp:2025
#3 0x0000000004cfacd0 in (anonymous
namespace)::ScalarExprEmitter::VisitCXXDeleteExpr (this=0x7fffffff3650,
E=0x808895150) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExprScalar.cpp:597
#4 0x0000000004cf5b13 in clang::StmtVisitorBase<clang::make_ptr, (anonymous
namespace)::ScalarExprEmitter, llvm::Value*>::Visit (this=0x7fffffff3650,
S=0x808895150) at tools/clang/include/clang/AST/StmtNodes.inc:239
#5 0x0000000004cee3e9 in (anonymous namespace)::ScalarExprEmitter::Visit
(this=0x7fffffff3650, E=0x808895150) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExprScalar.cpp:358
#6 0x0000000004cee333 in clang::CodeGen::CodeGenFunction::EmitScalarExpr
(this=0x7fffffff40f0, E=0x808895150, IgnoreResultAssign=true) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExprScalar.cpp:3833
#7 0x0000000004c06b07 in clang::CodeGen::CodeGenFunction::EmitAnyExpr
(this=0x7fffffff40f0, E=0x808895150, aggSlot=..., ignoreResult=true) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExpr.cpp:178
#8 0x0000000004c06a2e in clang::CodeGen::CodeGenFunction::EmitIgnoredExpr
(this=0x7fffffff40f0, E=0x808895150) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExpr.cpp:163
#9 0x0000000004be3a30 in clang::CodeGen::CodeGenFunction::EmitStmt
(this=0x7fffffff40f0, S=0x808895150, Attrs=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:116
#10 0x0000000004bf108c in
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope
(this=0x7fffffff40f0, S=..., GetLast=false, AggSlot=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:390
#11 0x0000000004bf048e in clang::CodeGen::CodeGenFunction::EmitCompoundStmt
(this=0x7fffffff40f0, S=..., GetLast=false, AggSlot=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:380
#12 0x0000000004be445c in clang::CodeGen::CodeGenFunction::EmitSimpleStmt
(this=0x7fffffff40f0, S=0x808895178) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:353
#13 0x0000000004be385e in clang::CodeGen::CodeGenFunction::EmitStmt
(this=0x7fffffff40f0, S=0x808895178, Attrs=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGStmt.cpp:53
#14 0x0000000004bbb9ce in clang::CodeGen::CodeGenFunction::EmitDestructorBody
(this=0x7fffffff40f0, Args=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGClass.cpp:1486
#15 0x0000000004b9be13 in clang::CodeGen::CodeGenFunction::GenerateCode
(this=0x7fffffff40f0, GD=..., Fn=0x808754888, FnInfo=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1312
#16 0x0000000004bd3f45 in clang::CodeGen::CodeGenModule::codegenCXXStructor
(this=0x8086f7000, MD=0x8088943a8, Type=clang::CodeGen::StructorType::Base) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGCXX.cpp:231
#17 0x0000000004e5fdcc in (anonymous namespace)::ItaniumCXXABI::emitCXXStructor
(this=0x80875bf40, MD=0x8088943a8, Type=clang::CodeGen::StructorType::Base) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp:3681
#18 0x0000000004a09029 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition
(this=0x8086f7000, GD=..., GV=0x808754888) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:2277
#19 0x00000000049fb252 in clang::CodeGen::CodeGenModule::EmitDeferred
(this=0x8086f7000) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:1702
#20 0x00000000049fb2ae in clang::CodeGen::CodeGenModule::EmitDeferred
(this=0x8086f7000) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:1708
#21 0x00000000049fb2ae in clang::CodeGen::CodeGenModule::EmitDeferred
(this=0x8086f7000) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:1708
#22 0x00000000049fb2ae in clang::CodeGen::CodeGenModule::EmitDeferred
(this=0x8086f7000) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:1708
#23 0x00000000049f9385 in clang::CodeGen::CodeGenModule::Release
(this=0x8086f7000) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenModule.cpp:393
#24 0x0000000005579e84 in (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit (this=0x808805000,
Ctx=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/ModuleBuilder.cpp:265
#25 0x0000000005571f52 in clang::BackendConsumer::HandleTranslationUnit
(this=0x808751300, C=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenAction.cpp:236
#26 0x0000000006051122 in clang::ParseAST (S=..., PrintStats=false,
SkipFunctionBodies=false) at
/home/dim/src/llvm/trunk/tools/clang/lib/Parse/ParseAST.cpp:164
#27 0x0000000005380931 in clang::ASTFrontendAction::ExecuteAction
(this=0x8086cf3c0) at
/home/dim/src/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:1005
#28 0x000000000556d9b9 in clang::CodeGenAction::ExecuteAction
(this=0x8086cf3c0) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CodeGenAction.cpp:1043
#29 0x000000000537fec0 in clang::FrontendAction::Execute (this=0x8086cf3c0) at
/home/dim/src/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:904
#30 0x00000000051f760f in clang::CompilerInstance::ExecuteAction
(this=0x808751000, Act=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/Frontend/CompilerInstance.cpp:991
#31 0x000000000555f5a6 in clang::ExecuteCompilerInvocation (Clang=0x808751000)
at
/home/dim/src/llvm/trunk/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:255
#32 0x0000000001e398a7 in cc1_main (Argv=..., Argv0=0x7fffffffe938
"/home/dim/obj/clang-trunk-r327649/bin/clang", MainAddr=0x1e25280
<GetExecutablePath(char const*, bool)>) at
/home/dim/src/llvm/trunk/tools/clang/tools/driver/cc1_main.cpp:221
#33 0x0000000001e28549 in ExecuteCC1Tool (argv=..., Tool=...) at
/home/dim/src/llvm/trunk/tools/clang/tools/driver/driver.cpp:309
#34 0x0000000001e2660f in main (argc_=6, argv_=0x7fffffffe6a8) at
/home/dim/src/llvm/trunk/tools/clang/tools/driver/driver.cpp:389
(gdb) up
#1 0x0000000004d17791 in EmitObjectDelete (CGF=..., DE=0x808895150, Ptr=...,
ElementType=...) at
/home/dim/src/llvm/trunk/tools/clang/lib/CodeGen/CGExprCXX.cpp:1865
1865 if (Dtor->isVirtual()) {
(gdb) print Dtor
$2 = (const clang::CXXDestructorDecl *) 0x0
I'm adding a few people who touched this area, maybe somebody has a clue.
Possible fix submitted as https://reviews.llvm.org/D44536, including the minimized test case.
Is there any current workaround to fix the issue ?
Like Removing all virtual destructors ?
When can this fix roll out ?
(In reply to Madan Kandula from comment #4)
> Is there any current workaround to fix the issue ?
> Like Removing all virtual destructors ?
The easiest workaround is to move the VMMaps::Global::~Global() implementation
into VMMapsMain.cpp, e.g. don't inline in in the class declaration in Global.h.
> When can this fix roll out ?
Since you are using a clang version supplied by Android, you will have to check
with that organization. Usually fixes like these get committed relatively
quickly in clang trunk, but backporting them to older branches is not often
done, certainly not with the 5.0 branch. The maintainer(s) of your distro's
packages might be more receptive to including smallish bugfixes.
Hi Dimitry
Thank you very much ! You are simply awesome ! It fixed the problem.
Cheers,
Madan
VMMapsMain-263a78.zip
(476221 bytes, application/zip)