[llvm-bugs] [Bug 24622] New: clang crashes on invalid code on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 28 18:03:11 PDT 2015


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

            Bug ID: 24622
           Summary: clang crashes on invalid code on x86_64-linux-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk (and clang 3.6.x) crashes when compiling the following
(invalid) code in both 32-bit and 64-bit modes on x86_64-linux-gnu. 

This is a regression from 3.5.x. 

$ clang-trunk -v
clang version 3.8.0 (trunk 246314)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ 
$ clang-3.5 -O0 -c small.c
small.c:2:12: error: redefinition of 'rint' as different kind of symbol
struct S0 *rint; 
           ^
small.c:2:12: note: previous definition is here
small.c:7:15: warning: comparison of distinct pointer types ('double
(*)(double)' and 'struct S0 *')
      [-Wcompare-distinct-pointer-types]
  return rint == &a; 
         ~~~~ ^  ~~
small.c:1:11: error: tentative definition has type 'struct S0' that is never
completed
struct S0 a;
          ^
small.c:1:8: note: forward declaration of 'struct S0'
struct S0 a;
       ^
1 warning and 2 errors generated.
$ 
$ clang-trunk -O0 -c small.c
small.c:2:12: error: redefinition of 'rint' as different kind of symbol
struct S0 *rint; 
           ^
small.c:2:12: note: previous definition is here
small.c:7:15: warning: comparison of distinct pointer types ('double
(*)(double)' and 'struct S0 *')
      [-Wcompare-distinct-pointer-types]
  return rint == &a; 
         ~~~~ ^  ~~
clang: /tmp/llvm/tools/clang/lib/AST/RecordLayoutBuilder.cpp:2868: const
clang::ASTRecordLayout &clang::ASTContext::getASTRecordLayout(const
clang::RecordDecl *) const: Assertion `D && "Cannot get layout of forward
declarations!"' failed.
#0 0x2be0e8d llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x2be0e8d)
#1 0x2be0516 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x2be0516)
#2 0x2be232a (/usr/local/clang-trunk/bin/clang+0x2be232a)
#3 0x7f4629182340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x7f462811dcc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x7f46281210d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x7f4628116b86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x7f4628116c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x16b4815 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*)
const (/usr/local/clang-trunk/bin/clang+0x16b4815)
#9 0x153be55 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const
(/usr/local/clang-trunk/bin/clang+0x153be55)
#10 0x153b9fc clang::ASTContext::getTypeInfo(clang::Type const*) const
(/usr/local/clang-trunk/bin/clang+0x153b9fc)
#11 0x153c218 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const
(/usr/local/clang-trunk/bin/clang+0x153c218)
#12 0x153b9fc clang::ASTContext::getTypeInfo(clang::Type const*) const
(/usr/local/clang-trunk/bin/clang+0x153b9fc)
#13 0x153b7ac clang::ASTContext::getTypeInfoInChars(clang::Type const*) const
(/usr/local/clang-trunk/bin/clang+0x153b7ac)
#14 0x165f0fd (/usr/local/clang-trunk/bin/clang+0x165f0fd)
#15 0x165a447 (/usr/local/clang-trunk/bin/clang+0x165a447)
#16 0x163d65f (/usr/local/clang-trunk/bin/clang+0x163d65f)
#17 0x163984d (/usr/local/clang-trunk/bin/clang+0x163984d)
#18 0x163b465 clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const
(/usr/local/clang-trunk/bin/clang+0x163b465)
#19 0xe8922d clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xe8922d)
#20 0xfd5656 clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*)
(/usr/local/clang-trunk/bin/clang+0xfd5656)
#21 0xfd4e88 clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*,
clang::Scope*) (/usr/local/clang-trunk/bin/clang+0xfd4e88)
#22 0xc20710 clang::Parser::ParseReturnStatement()
(/usr/local/clang-trunk/bin/clang+0xc20710)
#23 0xc1b7d7
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang+0xc1b7d7)
#24 0xc1ab1f
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*)
(/usr/local/clang-trunk/bin/clang+0xc1ab1f)
#25 0xc2217f clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/clang-trunk/bin/clang+0xc2217f)
#26 0xc229a3 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang+0xc229a3)
#27 0xb9a51d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/local/clang-trunk/bin/clang+0xb9a51d)
#28 0xbb1f2b clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned
int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang+0xbb1f2b)
#29 0xb99b2d
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang+0xb99b2d)
#30 0xb9950a
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang+0xb9950a)
#31 0xb9871a
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang+0xb9871a)
#32 0xb97b8a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang+0xb97b8a)
#33 0xb93726 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xb93726)
#34 0x76f745 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x76f745)
#35 0x73e1ac clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x73e1ac)
#36 0x71fa07 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x71fa07)
#37 0x715dd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x715dd5)
#38 0x71e13c main (/usr/local/clang-trunk/bin/clang+0x71e13c)
#39 0x7f4628108ec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#40 0x715861 _start (/usr/local/clang-trunk/bin/clang+0x715861)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.24
-dwarf-column-info -coverage-file
/data2/20150828-clang-build-m32-m64-O0-O1-Os-O2-O3-test98/small.c -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.8.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.8.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir
/data2/20150828-clang-build-m32-m64-O0-O1-Os-O2-O3-test98 -ferror-limit 19
-fmessage-length 113 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c small.c 
1.    small.c:7:20: current parser token ';'
2.    small.c:6:1: parsing function body 'fn1'
3.    small.c:6:1: in compound statement ('{}')
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (trunk 246314)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
clang: 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: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/small-4c1d76.c
clang: note: diagnostic msg: /tmp/small-4c1d76.sh
clang: note: diagnostic msg: 

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


--------------------------


struct S0 a;
struct S0 *rint; 

int
fn1 ()
{
  return rint == &a; 
}

-- 
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/20150829/48ac7111/attachment.html>


More information about the llvm-bugs mailing list