[llvm-bugs] [Bug 27126] New: clang crashes on C++ code with oversized bit-field

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 29 23:58:02 PDT 2016


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

            Bug ID: 27126
           Summary: clang crashes on C++ code with oversized bit-field
           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 (as well 3.5.x and later) crashes when compiling the
following C++ test case on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.4.x.


$ clang++ -v
clang version 3.9.0 (trunk 264702)
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++ -c small.cpp
small.cpp:4:12: warning: width of bit-field 'f' (10000000 bits) exceeds the
width of its type; value will be truncated to 32 bits [-Wbitfield-width]
  unsigned f : 10000000; 
           ^
clang-3.9: /tmp/llvm-builder/llvm-source-trunk/lib/IR/Type.cpp:251: static
llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int):
Assertion `NumBits <= MAX_INT_BITS && "bitwidth too large"' failed.
#0 0x0000000001d5d365 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d5d365)
#1 0x0000000001d5b2f6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1d5b2f6)
#2 0x0000000001d5b514 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d5b514)
#3 0x00007f82c1585340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f82c07a3cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f82c07a70d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f82c079cb86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f82c079cc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000001a1301a llvm::IntegerType::get(llvm::LLVMContext&, unsigned int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1a1301a)
#9 0x0000000001ecac8e (anonymous
namespace)::CGRecordLowering::accumulateFields()
(/usr/local/clang-trunk/bin/clang-3.9+0x1ecac8e)
#10 0x0000000001ecf532 (anonymous namespace)::CGRecordLowering::lower(bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x1ecf532)
#11 0x0000000001ed1a46
clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*,
llvm::StructType*) (/usr/local/clang-trunk/bin/clang-3.9+0x1ed1a46)
#12 0x0000000001f5a38e
clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*)
(/usr/local/clang-trunk/bin/clang-3.9+0x1f5a38e)
#13 0x0000000001f5bb6d
clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType)
(/usr/local/clang-trunk/bin/clang-3.9+0x1f5bb6d)
#14 0x0000000001fd7d4c
clang::CodeGen::CodeGenTypes::GetFunctionType(clang::CodeGen::CGFunctionInfo
const&) (/usr/local/clang-trunk/bin/clang-3.9+0x1fd7d4c)
#15 0x0000000001f2adac
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f2adac)
#16 0x0000000001f38221
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/local/clang-trunk/bin/clang-3.9+0x1f38221)
#17 0x0000000001f39114
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/usr/local/clang-trunk/bin/clang-3.9+0x1f39114)
#18 0x0000000001f3965d
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) [clone
.part.6083] (/usr/local/clang-trunk/bin/clang-3.9+0x1f3965d)
#19 0x00000000024b479c (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/usr/local/clang-trunk/bin/clang-3.9+0x24b479c)
#20 0x00000000024af36c
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/usr/local/clang-trunk/bin/clang-3.9+0x24af36c)
#21 0x00000000027ec186 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x27ec186)
#22 0x00000000024afbee clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x24afbee)
#23 0x000000000219d63e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x219d63e)
#24 0x0000000002176806
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2176806)
#25 0x0000000002227052
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2227052)
#26 0x0000000000ac2838 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xac2838)
#27 0x0000000000a7e92d main (/usr/local/clang-trunk/bin/clang-3.9+0xa7e92d)
#28 0x00007f82c078eec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#29 0x0000000000abe8a4 _start (/usr/local/clang-trunk/bin/clang-3.9+0xabe8a4)
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 160
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp 
1.    <eof> parser at end of file
2.    small.cpp:13:6: LLVM IR generation of declaration 'B::m'
3.    small.cpp:13:6: Generating code for declaration 'B::m'
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 264702)
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-b198fa.cpp
clang-3.9: note: diagnostic msg: /tmp/small-b198fa.sh
clang-3.9: note: diagnostic msg: 

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


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


class A
{
public:
  unsigned f : 10000000; 
};

class B
{
public:
  A m ();
};

A B::m ()
{
  return 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/20160330/ab72800e/attachment-0001.html>


More information about the llvm-bugs mailing list