[llvm-bugs] [Bug 25702] New: Crash comparing addresses of incomplete types

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 1 19:44:37 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25702

            Bug ID: 25702
           Summary: Crash comparing addresses of incomplete types
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: trprince at synopsys.com
                CC: llvm-bugs at lists.llvm.org, sig-clang-bugs at synopsys.com
    Classification: Unclassified

The following code triggers an assertion failure or a segfault when asserts are
disabled:

$ cat bad.cpp
struct S;
extern S a;
extern S b;
bool c = (void *)&a == (int *)&b;
$ clang -c bad.cpp
clang-3.7: ../tools/clang/lib/AST/RecordLayoutBuilder.cpp:2883: const
clang::ASTRecordLayout& clang::ASTContext::getASTRecordLayout(const
clang::RecordDecl*) const: Assertion `D && "Cannot get layout of forward
declarations!"' failed.
#0 0x28b45c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x28b45c2)
#1 0x28b493e PrintStackTraceSignalHandler(void*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x28b493e)
#2 0x28b344a SignalHandler(int) (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x28b344a)
#3 0x7f9ce2ee8cb0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xfcb0)
#4 0x7f9ce20ae0d5 gsignal
/build/buildd/eglibc-2.15/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:64:0
#5 0x7f9ce20b183b abort /build/buildd/eglibc-2.15/stdlib/abort.c:93:0
#6 0x7f9ce20a6d9e __assert_fail_base
/build/buildd/eglibc-2.15/assert/assert.c:55:0
#7 0x7f9ce20a6e42 (/lib/x86_64-linux-gnu/libc.so.6+0x2ee42)
#8 0x48b20ab clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*)
const (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x48b20ab)
#9 0x46b7aff clang::ASTContext::getTypeInfoImpl(clang::Type const*) const
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x46b7aff)
#10 0x46b6af3 clang::ASTContext::getTypeInfo(clang::Type const*) const
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x46b6af3)
#11 0x46b6975 clang::ASTContext::getTypeInfoInChars(clang::Type const*) const
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x46b6975)
#12 0x46b69f2 clang::ASTContext::getTypeInfoInChars(clang::QualType) const
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x46b69f2)
#13 0x46b80c9 clang::ASTContext::getTypeSizeInChars(clang::QualType) const
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x46b80c9)
#14 0x4827539 isOnePastTheEndOfCompleteObject(clang::ASTContext const&,
(anonymous namespace)::LValue const&)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x4827539)
#15 0x4829600 (anonymous
namespace)::IntExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x4829600)
#16 0x4861fa5 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous
namespace)::IntExprEvaluator, bool>::VisitBinEQ(clang::BinaryOperator const*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x4861fa5)
#17 0x4843fb4 clang::StmtVisitorBase<clang::make_const_ptr, (anonymous
namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x4843fb4)
#18 0x4830831 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&,
clang::Expr const*) (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x4830831)
#19 0x48310f2 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr
const*, clang::APValue&) (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x48310f2)
#20 0x4831c86 clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x4831c86)
#21 0x3cd370a clang::Sema::CheckForIntOverflow(clang::Expr*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3cd370a)
#22 0x3cd5244 clang::Sema::CheckCompletedExpr(clang::Expr*,
clang::SourceLocation, bool) (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3cd5244)
#23 0x3f58092 clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool, bool)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3f58092)
#24 0x3d44426 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*,
bool, bool) (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3d44426)
#25 0x3a34f09
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a34f09)
#26 0x3a33de8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned
int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a33de8)
#27 0x3a21aca
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a21aca)
#28 0x3a21bae
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a21bae)
#29 0x3a212e7
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a212e7)
#30 0x3a2076c
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a2076c)
#31 0x3a1943f clang::ParseAST(clang::Sema&, bool, bool)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x3a1943f)
#32 0x2e05dba clang::ASTFrontendAction::ExecuteAction()
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x2e05dba)
#33 0x316af9b clang::CodeGenAction::ExecuteAction()
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x316af9b)
#34 0x2e05877 clang::FrontendAction::Execute()
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x2e05877)
#35 0x2dc9d75 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x2dc9d75)
#36 0x2f0329d clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x2f0329d)
#37 0x13fee35 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x13fee35)
#38 0x13f70c6 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef)
(/opt/pkg/clang-3.7.0/bin/clang-3.7+0x13f70c6)
#39 0x13f76b6 main (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x13f76b6)
#40 0x7f9ce209976d __libc_start_main
/build/buildd/eglibc-2.15/csu/libc-start.c:258:0
#41 0x13f3f59 _start (/opt/pkg/clang-3.7.0/bin/clang-3.7+0x13f3f59)
Stack dump:
0.      Program arguments: /opt/pkg/clang-3.7.0/bin/clang-3.7 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
bad.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu
x86-64 -dwarf-column-info -coverage-file
/slowfs/sighome/trprince/lab/bz83784/bad.cpp -resource-dir
/opt/pkg/clang-3.7.0/bin/../lib/clang/3.7.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/backward
-internal-isystem /usr/local/include -internal-isystem
/opt/pkg/clang-3.7.0/bin/../lib/clang/3.7.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /slowfs/sighome/trprince/lab/bz83784 -ferror-limit 19
-fmessage-length 346 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o bad.o -x c++
bad.cpp
1.      bad.cpp:4:33: current parser token ';'
clang-3.7: error: unable to execute command: Aborted (core dumped)
clang-3.7: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang-3.7: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.7: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.7: note: diagnostic msg: /tmp/bad-2342c0.cpp
clang-3.7: note: diagnostic msg: /tmp/bad-2342c0.sh
clang-3.7: note: diagnostic msg:

********************
$

-- 
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/20151202/aeed362c/attachment.html>


More information about the llvm-bugs mailing list