[llvm-bugs] [Bug 28181] New: ICE on invalid code on x86_64-linux-gnu (Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed, clang::Sema::AddBuiltinOperatorCandidates)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 17 20:14:41 PDT 2016


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

            Bug ID: 28181
           Summary: ICE on invalid code on x86_64-linux-gnu (Assertion
                    `isa<X>(Val) && "cast<Ty>() argument of incompatible
                    type!"' failed,
                    clang::Sema::AddBuiltinOperatorCandidates)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code crashes the trunk on x86_64-linux-gnu in both 32-bit and
64-bit modes.

clang-3.5 and clang-3.6 do not crash. This is a regression starting from
clang-3.7.


$: clang-trunk -v
clang version 3.9.0 (trunk 272938) (llvm/trunk 272936)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.2
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.4
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
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$: 
$: clang-trunk small.c
small.c:6:22: error: use of undeclared identifier 'lock'; did you mean 'long'?
  audit_skb_queue = (lock);
                     ^~~~
                     long
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/include/llvm/Support/Casting.h:237:
typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X =
clang::CXXRecordDecl; Y = clang::RecordDecl; typename llvm::cast_retty<X,
Y*>::ret_type = clang::CXXRecordDecl*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
#0 0x0000000001c6b8b5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1c6b8b5)
#1 0x0000000001c69776 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1c69776)
#2 0x0000000001c69994 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1c69994)
#3 0x00007fb8904ef8d0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#4 0x00007fb88f72d067 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35067)
#5 0x00007fb88f72e448 abort (/lib/x86_64-linux-gnu/libc.so.6+0x36448)
#6 0x00007fb88f726266 (/lib/x86_64-linux-gnu/libc.so.6+0x2e266)
#7 0x00007fb88f726312 (/lib/x86_64-linux-gnu/libc.so.6+0x2e312)
#8 0x00000000009f5eb2 llvm::isa_impl_cl<clang::FunctionProtoType,
clang::FunctionType const*>::doit(clang::FunctionType const*) [clone .part.911]
(/usr/local/clang-trunk/bin/clang-3.9+0x9f5eb2)
#9 0x0000000002b80854
clang::Sema::AddBuiltinOperatorCandidates(clang::OverloadedOperatorKind,
clang::SourceLocation, llvm::ArrayRef<clang::Expr*>,
clang::OverloadCandidateSet&) (/usr/local/clang-trunk/bin/clang-3.9+0x2b80854)
#10 0x0000000002b89f99
clang::Sema::CreateOverloadedBinOp(clang::SourceLocation,
clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*,
clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2b89f99)
#11 0x00000000029ef4e1 BuildOverloadedBinOp(clang::Sema&, clang::Scope*,
clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x29ef4e1)
#12 0x0000000002a21c17 clang::Sema::BuildBinOp(clang::Scope*,
clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2a21c17)
#13 0x0000000002a21fac clang::Sema::ActOnBinOp(clang::Scope*,
clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2a21fac)
#14 0x00000000026dd24b
clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*,
true>, clang::prec::Level) (/usr/local/clang-trunk/bin/clang-3.9+0x26dd24b)
#15 0x00000000026dce19
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/usr/local/clang-trunk/bin/clang-3.9+0x26dce19)
#16 0x00000000026dce89
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/usr/local/clang-trunk/bin/clang-3.9+0x26dce89)
#17 0x0000000002717e76 clang::Parser::ParseExprStatement()
(/usr/local/clang-trunk/bin/clang-3.9+0x2717e76)
#18 0x0000000002718997
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2718997)
#19 0x0000000002718aee
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2718aee)
#20 0x000000000271c4ff clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x271c4ff)
#21 0x000000000271eac1 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-3.9+0x271eac1)
#22 0x00000000026a39e0
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/local/clang-trunk/bin/clang-3.9+0x26a39e0)
#23 0x00000000026c1abc clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-3.9+0x26c1abc)
#24 0x000000000269ed5d
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-3.9+0x269ed5d)
#25 0x000000000269f3e1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.222]
(/usr/local/clang-trunk/bin/clang-3.9+0x269f3e1)
#26 0x000000000269f41f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-3.9+0x269f41f)
#27 0x00000000026a1100
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-3.9+0x26a1100)
#28 0x00000000026a18b0
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-3.9+0x26a18b0)
#29 0x000000000269c16b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x269c16b)
#30 0x000000000236afbb clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x236afbb)
#31 0x000000000209aa4e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x209aa4e)
#32 0x0000000002071526
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2071526)
#33 0x0000000002123942
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2123942)
#34 0x0000000000b0eba8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xb0eba8)
#35 0x0000000000ac3325 main (/usr/local/clang-trunk/bin/clang-3.9+0xac3325)
#36 0x00007fb88f719b45 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b45)
#37 0x0000000000b0ad04 _start (/usr/local/clang-trunk/bin/clang-3.9+0xb0ad04)
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.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 -dwarf-column-info -debugger-tuning=gdb
-resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.9.0 -c-isystem .
-c-isystem /usr/local/include/csmith -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
-fdebug-compilation-dir
/home/cnsun/workspace/meta-compiler/error-fuzzer/temp-runs/IdentifierSubstituionFuzzingEngine/crash/20160617-edu.ucdavis.error.compiler.CompilerTestConfig at 4e6a55c3--O3-c-Weverything-std=c11-build-034532
-ferror-limit 19 -fmessage-length 154 -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/small-afa38c.o -x c
small.c 
1.    small.c:6:27: current parser token ';'
2.    small.c:5:12: parsing function body 'fn1'
3.    small.c:5:12: in compound statement ('{}')
clang-3.9: error: unable to execute command: Aborted
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 272938) (llvm/trunk 272936)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/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-62d1d4.c
clang-3.9: note: diagnostic msg: /tmp/small-62d1d4.sh
clang-3.9: note: diagnostic msg: 

********************
$: cat small.c
struct spinlock_t {
  int lock;
} audit_skb_queue;

void fn1() {
  audit_skb_queue = (lock);
}  
$:

-- 
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/20160618/78f69c0d/attachment-0001.html>


More information about the llvm-bugs mailing list