Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang crashes on valid C++ code #27518

Closed
zhendongsu opened this issue Mar 30, 2016 · 5 comments
Closed

clang crashes on valid C++ code #27518

zhendongsu opened this issue Mar 30, 2016 · 5 comments
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" regression

Comments

@zhendongsu
Copy link

Bugzilla Link 27144
Version trunk
OS All
CC @DougGregor,@hfinkel,@slacka,@zygoloid

Extended Description

The current clang trunk (as well 3.2.x and later) crashes when compiling the following test case on x86_64-linux-gnu in both 32-bit and 64-bit modes.

This is a regression from 3.1.x.

$ clang++ -v
clang version 3.9.0 (trunk 264841)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/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.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.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.5
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.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.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.1 -c small.cpp
$
$ clang++ -c small.cpp
clang-3.9: /tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/AST/ExprClassification.cpp:56: Cl clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const: Assertion `getValueKind() == VK_LValue' failed.
#​0 0x0000000001d5a075 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/clang-trunk/bin/clang-3.9+0x1d5a075)
#​1 0x0000000001d58006 llvm::sys::RunSignalHandlers() (/usr/local/clang-trunk/bin/clang-3.9+0x1d58006)
#​2 0x0000000001d58224 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-3.9+0x1d58224)
#​3 0x00007f86dd97e340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#​4 0x00007f86dcb9ccc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#​5 0x00007f86dcba00d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#​6 0x00007f86dcb95b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#​7 0x00007f86dcb95c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#​8 0x0000000003276605 clang::Expr::ClassifyImpl(clang::ASTContext&, clang::SourceLocation*) const (/usr/local/clang-trunk/bin/clang-3.9+0x3276605)
#​9 0x0000000003276717 clang::Expr::isModifiableLvalue(clang::ASTContext&, clang::SourceLocation*) const (/usr/local/clang-trunk/bin/clang-3.9+0x3276717)
#​10 0x0000000002b72819 CheckForModifiableLvalue(clang::Expr*, clang::SourceLocation, clang::Sema&) (/usr/local/clang-trunk/bin/clang-3.9+0x2b72819)
#​11 0x0000000002b89e9e clang::Sema::CheckAssignmentOperands(clang::Expr*, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, clang::QualType) (/usr/local/clang-trunk/bin/clang-3.9+0x2b89e9e)
#​12 0x0000000002b8b0d7 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b8b0d7)
#​13 0x0000000002b8bd0a clang::Sema::BuildBinOp(clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b8bd0a)
#​14 0x0000000002b8c02a clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b8c02a)
#​15 0x000000000282ace5 clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) (/usr/local/clang-trunk/bin/clang-3.9+0x282ace5)
#​16 0x000000000282a5e9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-3.9+0x282a5e9)
#​17 0x000000000282a659 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-3.9+0x282a659)
#​18 0x00000000028674b6 clang::Parser::ParseExprStatement() (/usr/local/clang-trunk/bin/clang-3.9+0x28674b6)
#​19 0x000000000286609f clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/usr/local/clang-trunk/bin/clang-3.9+0x286609f)
#​20 0x00000000028664be clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) (/usr/local/clang-trunk/bin/clang-3.9+0x28664be)
#​21 0x000000000286aa39 clang::Parser::ParseCompoundStatementBody(bool) (/usr/local/clang-trunk/bin/clang-3.9+0x286aa39)
#​22 0x000000000286dce5 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-3.9+0x286dce5)
#​23 0x00000000027f2471 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/usr/local/clang-trunk/bin/clang-3.9+0x27f2471)
#​24 0x00000000027f21ee clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/usr/local/clang-trunk/bin/clang-3.9+0x27f21ee)
#​25 0x0000000002822bf9 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int, clang::Decl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2822bf9)
#​26 0x000000000282391f clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) (/usr/local/clang-trunk/bin/clang-3.9+0x282391f)
#​27 0x0000000002805e38 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/usr/local/clang-trunk/bin/clang-3.9+0x2805e38)
#​28 0x00000000027ea5e4 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/usr/local/clang-trunk/bin/clang-3.9+0x27ea5e4)
#​29 0x00000000027ead41 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.228] (/usr/local/clang-trunk/bin/clang-3.9+0x27ead41)
#​30 0x00000000027ead7f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/usr/local/clang-trunk/bin/clang-3.9+0x27ead7f)
#​31 0x00000000027efb50 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-3.9+0x27efb50)
#​32 0x00000000027f0310 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) (/usr/local/clang-trunk/bin/clang-3.9+0x27f0310)
#​33 0x00000000027e7a10 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x27e7a10)
#​34 0x00000000024acb3e clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-3.9+0x24acb3e)
#​35 0x000000000219990e clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-3.9+0x219990e)
#​36 0x0000000002172806 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-3.9+0x2172806)
#​37 0x0000000002223692 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-3.9+0x2223692)
#​38 0x0000000000abf198 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-3.9+0xabf198)
#​39 0x0000000000a7b3dd main (/usr/local/clang-trunk/bin/clang-3.9+0xa7b3dd)
#​40 0x00007f86dcb87ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#​41 0x0000000000abb204 _start (/usr/local/clang-trunk/bin/clang-3.9+0xabb204)
Stack dump:
0. Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name small.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -coverage-file /data2/small.cpp -resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward -internal-isystem /usr/local/include -internal-isystem /usr/local/clang-trunk/bin/../lib/clang/3.9.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 /data2 -ferror-limit 19 -fmessage-length 110 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c++ small.cpp

  1. small.cpp:5:21: current parser token ';'
  2. small.cpp:1:1: parsing struct/union/class body 'A'
  3. small.cpp:4:3: parsing function body 'A'
  4. small.cpp:4:3: in compound statement ('{}')
    clang-3.9: error: unable to execute command: Aborted (core dumped)
    clang-3.9: error: clang frontend command failed due to signal (use -v to see invocation)
    clang version 3.9.0 (trunk 264841)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /usr/local/clang-trunk/bin
    clang-3.9: 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.9: 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.9: note: diagnostic msg: /tmp/small-c6a500.cpp
clang-3.9: note: diagnostic msg: /tmp/small-c6a500.sh
clang-3.9: note: diagnostic msg:


$


class A
{
A (double x)
{
imag x = 0.0;
}
};

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 11, 2019

This still can be reproduced as of 3bf8558.

$ cat /tmp/q.cc
class A {
A(double x) { imag x = 0.0; }
};
$ clang-check /tmp/q.cc --
assert.h assertion failed at clang/lib/AST/ExprClassification.cpp:56 in Cl clang::Expr::ClassifyImpl(clang::ASTContext &, clang::SourceLocation *) const: getValueKind() == VK_LValue

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 11, 2019

*** Bug llvm/llvm-bugzilla-archive#28122 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#28122

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@fhahn
Copy link
Contributor

fhahn commented Mar 17, 2022

Clang now produces the following error message and does not crash: https://clang.godbolt.org/z/93v54YTaj

<source>:5:1: error: unknown type name 'imag'
imag x = 0.0;
^
1 error generated.
Compiler returned: 1

@fhahn fhahn closed this as completed Mar 17, 2022
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Mar 17, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 17, 2022

@llvm/issue-subscribers-clang-frontend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" regression
Projects
None yet
Development

No branches or pull requests

4 participants