[llvm-bugs] [Bug 50911] New: ICE on valid code: {anonymous}::ConstantAggregateBuilder::add(llvm::Constant*, clang::CharUnits, bool): Assertion `(FirstElemToReplace == LastElemToReplace || AllowOverwrite) && "unexpectedly overwriting field"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 26 23:59:36 PDT 2021


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

            Bug ID: 50911
           Summary: ICE on valid code:
                    {anonymous}::ConstantAggregateBuilder::add(llvm::Const
                    ant*, clang::CharUnits, bool): Assertion
                    `(FirstElemToReplace == LastElemToReplace ||
                    AllowOverwrite) && "unexpectedly overwriting field"'
                    failed.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: cnsun at uwaterloo.ca
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Gcc can compile the test program.

$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
699d47472c3f7c5799fe75486689545179cfba03)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$ cat mutant.c
typedef struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
struct {
int c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c,
    l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c,
    l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c,
    l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c, l} c,
    l} c, l;
char ch} pstr;
pstr ao = { };

$ clang-trunk -O1 -w mutant.c
clang-13:
/tmp/tmp.MZZAoX1zOr-clang-builder/llvm-project/clang/lib/CodeGen/CGExprConstant.cpp:170:
bool {anonymous}::ConstantAggregateBuilder::add(llvm::Constant*,
clang::CharUnits, bool): Assertion `(FirstElemToReplace == LastElemToReplace ||
AllowOverwrite) && "unexpectedly overwriting field"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /scratch/software/clang-trunk/bin/clang-13 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free
-main-file-name mutant.c -mrelocation-model static -mframe-pointer=none
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables
-target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb
-fcoverage-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210626_000613_0224/delta/perses_result
-resource-dir /scratch/software/clang-trunk/lib/clang/13.0.0 -c-isystem .
-c-isystem /usr/local/include/cmsith -internal-isystem
/scratch/software/clang-trunk/lib/clang/13.0.0/include -internal-isystem
/usr/local/include -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O1
-w
-fdebug-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210626_000613_0224/delta/perses_result
-ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1
-o /tmp/mutant-ef8f0b.o -x c mutant.c
1.      <eof> parser at end of file
2.      mutant.c:87:6: LLVM IR generation of declaration 'ao'
3.      mutant.c:87:6: Generating code for declaration 'ao'
 #0 0x000056262fbf3684 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000056262fbf0e3e SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f7e52b5b3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
 #3 0x00007f7e525fa18b raise
/build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007f7e525d9859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
 #5 0x00007f7e525d9729 get_sysdep_segment_value
/build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8
 #6 0x00007f7e525d9729 _nl_load_domain
/build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34
 #7 0x00007f7e525eaf36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x000056262ff5a256 (anonymous
namespace)::ConstantAggregateBuilder::add(llvm::Constant*, clang::CharUnits,
bool) CGExprConstant.cpp:0:0
 #9 0x000056262ff60c03 (anonymous
namespace)::ConstStructBuilder::Build(clang::InitListExpr*, bool)
CGExprConstant.cpp:0:0
#10 0x000056262ff615de (anonymous
namespace)::ConstStructBuilder::BuildStruct(clang::CodeGen::ConstantEmitter&,
clang::InitListExpr*, clang::QualType) CGExprConstant.cpp:0:0
#11 0x000056262ff6030c clang::StmtVisitorBase<std::add_pointer, (anonymous
namespace)::ConstExprEmitter, llvm::Constant*,
clang::QualType>::Visit(clang::Stmt*, clang::QualType) CGExprConstant.cpp:0:0
#12 0x000056262ff6413f
clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl
const&) (/scratch/software/clang-trunk/bin/clang-13+0x3cce13f)
#13 0x000056262ff643b5
clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&)
(/scratch/software/clang-trunk/bin/clang-13+0x3cce3b5)
#14 0x00005626300242c5
clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*,
bool) (/scratch/software/clang-trunk/bin/clang-13+0x3d8e2c5)
#15 0x0000562630047451
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/scratch/software/clang-trunk/bin/clang-13+0x3db1451)
#16 0x000056263004796b
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/scratch/software/clang-trunk/bin/clang-13+0x3db196b)
#17 0x000056263005037c
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0)
CodeGenModule.cpp:0:0
#18 0x0000562630d53099 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
ModuleBuilder.cpp:0:0
#19 0x0000562630d45280
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/scratch/software/clang-trunk/bin/clang-13+0x4aaf280)
#20 0x0000562631e08b64 clang::ParseAST(clang::Sema&, bool, bool)
(/scratch/software/clang-trunk/bin/clang-13+0x5b72b64)
#21 0x0000562630d50218 clang::CodeGenAction::ExecuteAction()
(/scratch/software/clang-trunk/bin/clang-13+0x4aba218)
#22 0x00005626305ffa79 clang::FrontendAction::Execute()
(/scratch/software/clang-trunk/bin/clang-13+0x4369a79)
#23 0x0000562630592cc6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/scratch/software/clang-trunk/bin/clang-13+0x42fccc6)
#24 0x00005626306dd9c0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/scratch/software/clang-trunk/bin/clang-13+0x44479c0)
#25 0x000056262d4fb696 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/scratch/software/clang-trunk/bin/clang-13+0x1265696)
#26 0x000056262d4f79d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#27 0x000056262d4250e6 main
(/scratch/software/clang-trunk/bin/clang-13+0x118f0e6)
#28 0x00007f7e525db0b3 __libc_start_main
/build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
#29 0x000056262d4f754e _start
(/scratch/software/clang-trunk/bin/clang-13+0x126154e)
clang-13: error: unable to execute command: Aborted (core dumped)
clang-13: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
699d47472c3f7c5799fe75486689545179cfba03)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
clang-13: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg: /tmp/mutant-97fb78.c
clang-13: note: diagnostic msg: /tmp/mutant-97fb78.sh
clang-13: note: diagnostic msg:

********************

-- 
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/20210627/141f7b1f/attachment.html>


More information about the llvm-bugs mailing list