https://llvm.org/bugs/show_bug.cgi?id=28172
Bug ID: 28172 Summary: clang crashes on invalid code (with too few arguments to __builtin_signbit) without any proper diagnostics Product: clang Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: -New Bugs Assignee: unassignedclangb...@nondot.org Reporter: s...@cs.ucdavis.edu CC: llvm-bugs@lists.llvm.org Classification: Unclassified The current clang trunk and 3.8.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.7.x. $ clang -v clang version 3.9.0 (trunk 272993) 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.7 -c small.c small.c:3:22: error: too few arguments to function call, expected 1, have 0 __builtin_signbit (); ~~~~~~~~~~~~~~~~~ ^ 1 error generated. $ $ clang -c small.c small.c:3:3: warning: ignoring return value of function declared with const attribute [-Wunused-value] __builtin_signbit (); ^~~~~~~~~~~~~~~~~ clang-3.9: /tmp/llvm-builder/llvm-source-trunk/tools/clang/include/clang/AST/Expr.h:2218: const clang::Expr* clang::CallExpr::getArg(unsigned int) const: Assertion `Arg < NumArgs && "Arg access out of range!"' failed. #0 0x0000000001d1b425 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/clang-trunk/bin/clang-3.9+0x1d1b425) #1 0x0000000001d192b6 llvm::sys::RunSignalHandlers() (/usr/local/clang-trunk/bin/clang-3.9+0x1d192b6) #2 0x0000000001d194d4 SignalHandler(int) (/usr/local/clang-trunk/bin/clang-3.9+0x1d194d4) #3 0x00007fb0bf48d340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340) #4 0x00007fb0be6abcc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0 #5 0x00007fb0be6af0d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0 #6 0x00007fb0be6a4b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0 #7 0x00007fb0be6a4c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32) #8 0x000000000089907e llvm::isa_impl_cl<clang::ImplicitCastExpr, clang::Expr const*>::doit(clang::Expr const*) [clone .part.414] (/usr/local/clang-trunk/bin/clang-3.9+0x89907e) #9 0x00000000020a8ac9 (/usr/local/clang-trunk/bin/clang-3.9+0x20a8ac9) #10 0x00000000020d0872 clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::FunctionDecl const*, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/usr/local/clang-trunk/bin/clang-3.9+0x20d0872) #11 0x0000000002000220 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) (/usr/local/clang-trunk/bin/clang-3.9+0x2000220) #12 0x00000000008908f0 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) (/usr/local/clang-trunk/bin/clang-3.9+0x8908f0) #13 0x0000000002026c13 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) (/usr/local/clang-trunk/bin/clang-3.9+0x2026c13) #14 0x0000000002027333 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2027333) #15 0x0000000001fef44f clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x1fef44f) #16 0x0000000002000bdd clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/local/clang-trunk/bin/clang-3.9+0x2000bdd) #17 0x0000000001eaa6ec clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-3.9+0x1eaa6ec) #18 0x0000000001eab3df clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/local/clang-trunk/bin/clang-3.9+0x1eab3df) #19 0x0000000001ed12f2 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&, clang::Stmt const*) (/usr/local/clang-trunk/bin/clang-3.9+0x1ed12f2) #20 0x0000000001edba4e clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/local/clang-trunk/bin/clang-3.9+0x1edba4e) #21 0x0000000001efcc21 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1efcc21) #22 0x0000000001f0d381 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f0d381) #23 0x0000000001f0e299 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/local/clang-trunk/bin/clang-3.9+0x1f0e299) #24 0x0000000001f0e96d clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone .part.6217] (/usr/local/clang-trunk/bin/clang-3.9+0x1f0e96d) #25 0x000000000248b97b (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/local/clang-trunk/bin/clang-3.9+0x248b97b) #26 0x000000000248628c clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/usr/local/clang-trunk/bin/clang-3.9+0x248628c) #27 0x00000000027f0676 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x27f0676) #28 0x0000000002486d3e clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-3.9+0x2486d3e) #29 0x00000000021977fe clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-3.9+0x21977fe) #30 0x000000000216d266 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-3.9+0x216d266) #31 0x00000000022245c2 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-3.9+0x22245c2) #32 0x0000000000af0548 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-3.9+0xaf0548) #33 0x0000000000aa46dc main (/usr/local/clang-trunk/bin/clang-3.9+0xaa46dc) #34 0x00007fb0be696ec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0 #35 0x0000000000aec5b4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xaec5b4) 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 -coverage-file /data2/small.c -resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.9.0 -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 /data2/ -ferror-limit 19 -fmessage-length 226 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c small.c 1. <eof> parser at end of file 2. small.c:1:6: LLVM IR generation of declaration 'foo' 3. small.c:1:6: Generating code for declaration 'foo' 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 272993) 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-b8a809.c clang-3.9: note: diagnostic msg: /tmp/small-b8a809.sh clang-3.9: note: diagnostic msg: ******************** $ ---------------------------- void foo () { __builtin_signbit (); } -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs