[llvm-bugs] [Bug 32482] New: clang 5.0.0 (trunk 299152) crash if compile with -mms-bitfields and pack 1
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Mar 31 06:27:19 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32482
Bug ID: 32482
Summary: clang 5.0.0 (trunk 299152) crash if compile with
-mms-bitfields and pack 1
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: steven.shi at intel.com
CC: llvm-bugs at lists.llvm.org
Created attachment 18202
--> https://bugs.llvm.org/attachment.cgi?id=18202&action=edit
-mms-bitfields test case
Use Debug version clang 5.0.0 (trunk 299152) to compile the attached
ms-bitfields.c code. The clang crash with below error.
$ clang -mms-bitfields ms-bitfields.c
clang-5.0:
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:808:
clang::CodeGen::CGRecordLayout
*clang::CodeGen::CodeGenTypes::ComputeRecordLayout(const clang::RecordDecl *,
llvm::StructType *): Assertion `static_cast<unsigned>(Info.Offset) + Info.Size
<= Info.StorageSize && "Bitfield outside of its allocated storage"' failed.
#0 0x000000000204b169 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/jshi19/llvm/lib/Support/Unix/Signals.inc:398:11
#1 0x000000000204b319 PrintStackTraceSignalHandler(void*)
/home/jshi19/llvm/lib/Support/Unix/Signals.inc:462:1
#2 0x00000000020499b3 llvm::sys::RunSignalHandlers()
/home/jshi19/llvm/lib/Support/Signals.cpp:45:5
#3 0x000000000204b674 SignalHandler(int)
/home/jshi19/llvm/lib/Support/Unix/Signals.inc:252:1
#4 0x00007f24db888390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#5 0x00007f24da3f3428 gsignal
/build/glibc-9tT8Do/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#6 0x00007f24da3f502a abort /build/glibc-9tT8Do/glibc-2.23/stdlib/abort.c:91:0
#7 0x00007f24da3ebbd7 __assert_fail_base
/build/glibc-9tT8Do/glibc-2.23/assert/assert.c:92:0
#8 0x00007f24da3ebc82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#9 0x00000000023e0f9c
clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*,
llvm::StructType*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:809:3
#10 0x00000000025d937c
clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:699:28
#11 0x00000000025d7edc
clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:386:5
#12 0x00000000025d7de7
clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:84:19
#13 0x00000000023e373c (anonymous
namespace)::CGRecordLowering::getStorageType(clang::FieldDecl const*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:136:17
#14 0x00000000023e1ab3 (anonymous namespace)::CGRecordLowering::lowerUnion()
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:306:17
#15 0x00000000023e11c3 (anonymous namespace)::CGRecordLowering::lower(bool)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:265:5
#16 0x00000000023e0539
clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*,
llvm::StructType*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:689:3
#17 0x00000000025d937c
clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:699:28
#18 0x00000000025d7edc
clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:386:5
#19 0x00000000025d7de7
clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenTypes.cpp:84:19
#20 0x000000000245df41
clang::CodeGen::CodeGenFunction::ConvertTypeForMem(clang::QualType)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp:185:3
#21 0x00000000026ef37e
clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGDecl.cpp:1031:18
#22 0x00000000026ecea8
clang::CodeGen::CodeGenFunction::EmitAutoVarDecl(clang::VarDecl const&)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGDecl.cpp:913:30
#23 0x00000000026ec9cd
clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGDecl.cpp:175:1
#24 0x00000000026ec741 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl
const&) /home/jshi19/llvm/tools/clang/lib/CodeGen/CGDecl.cpp:131:49
#25 0x00000000023f52b6
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGStmt.cpp:1104:22
#26 0x00000000023ee90d
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGStmt.cpp:345:75
#27 0x00000000023ede1d clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*) /home/jshi19/llvm/tools/clang/lib/CodeGen/CGStmt.cpp:53:7
#28 0x00000000023f5e28
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CGStmt.cpp:380:42
#29 0x00000000024637e2
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1008:5
#30 0x000000000246428f
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1180:3
#31 0x0000000002484748
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp:3074:3
#32 0x000000000247f418
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp:1918:12
#33 0x0000000002482c8a
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp:1699:5
#34 0x00000000024872a1
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp:3801:38
#35 0x0000000002ff00c2 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
/home/jshi19/llvm/tools/clang/lib/CodeGen/ModuleBuilder.cpp:151:73
#36 0x0000000002fe97da
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:136:7
#37 0x0000000003f7fd49 clang::ParseAST(clang::Sema&, bool, bool)
/home/jshi19/llvm/tools/clang/lib/Parse/ParseAST.cpp:151:9
#38 0x0000000002a65e7c clang::ASTFrontendAction::ExecuteAction()
/home/jshi19/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:613:1
#39 0x0000000002fe7746 clang::CodeGenAction::ExecuteAction()
/home/jshi19/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:990:1
#40 0x0000000002a65920 clang::FrontendAction::Execute()
/home/jshi19/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:516:7
#41 0x00000000029f7407
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/jshi19/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:970:7
#42 0x0000000002bd43ca
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/jshi19/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:249:8
#43 0x0000000000d21b94 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/jshi19/llvm/tools/clang/tools/driver/cc1_main.cpp:221:11
#44 0x0000000000d15199 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef) /home/jshi19/llvm/tools/clang/tools/driver/driver.cpp:299:5
#45 0x0000000000d13e18 main
/home/jshi19/llvm/tools/clang/tools/driver/driver.cpp:380:5
#46 0x00007f24da3de830 __libc_start_main
/build/glibc-9tT8Do/glibc-2.23/csu/../csu/libc-start.c:325:0
#47 0x0000000000d12ff9 _start (/usr/local/bin/clang-5.0+0xd12ff9)
Stack dump:
0. Program arguments: /usr/local/bin/clang-5.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
ms-bitfields.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -mms-bitfields -munwind-tables
-fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-resource-dir /usr/local/lib/clang/5.0.0 -internal-isystem /usr/local/include
-internal-isystem /usr/local/lib/clang/5.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdebug-compilation-dir
/home/jshi19/llvmwrongcode -ferror-limit 19 -fmessage-length 100
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/ms-bitfields-0d09cd.o -x c ms-bitfields.c
1. <eof> parser at end of file
2. ms-bitfields.c:21:1: LLVM IR generation of declaration 'Procedure'
3. ms-bitfields.c:21:1: Generating code for declaration 'Procedure'
clang-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 299152)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-5.0: 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-5.0: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-5.0: note: diagnostic msg: /tmp/ms-bitfields-7f7954.c
clang-5.0: note: diagnostic msg: /tmp/ms-bitfields-7f7954.sh
clang-5.0: note: diagnostic msg:
********************
The ms-bitfields.c code content is in below:
#pragma pack(push, 1)
typedef union {
struct {
int : 3; // Bits 2:0
int a : 9; // Bits 11:3
int : 12; // Bits 23:12
int b : 17; // Bits 40:24
int : 7; // Bits 47:41
int c : 4; // Bits 51:48
int : 4; // Bits 55:52
int d : 3; // Bits 58:56
int : 5; // Bits 63:59
} Bits;
} HEADER;
#pragma pack(pop)
int
Procedure (
int *const input
)
{
HEADER data;
data.Bits.a = 0;
return 0;
}
--
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/20170331/bf0c938c/attachment-0001.html>
More information about the llvm-bugs
mailing list