Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when compiling with -O2 -g #51675

Closed
theo-lw opened this issue Oct 28, 2021 · 4 comments
Closed

ICE when compiling with -O2 -g #51675

theo-lw opened this issue Oct 28, 2021 · 4 comments
Labels
bugzilla Issues migrated from bugzilla clang:codegen

Comments

@theo-lw
Copy link
Contributor

theo-lw commented Oct 28, 2021

Bugzilla Link 52333
Version trunk
OS All
CC @chengniansun,@dwblaikie,@RKSimon,@zygoloid

Extended Description

See below

$ clang-trunk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 91434d4)
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 formatted_program-e3ce1c.c
#pragma pack(1)
struct a {
signed b : 25;
unsigned : 19;
signed : 28
};
c;
d() {
int e = 0;
for (;;) {
for (; c;)
;
for (; e <= 0; e++) {
struct a f[6][1] = {81298, 27563224};
c &= 4;
f[5][0].b = e;
}
}
}
main() {}
$
$ clang-trunk -O2 -g formatted_program-e3ce1c.c
formatted_program-e3ce1c.c:5:14: warning: expected ';' at end of declaration list
signed : 28
^
;
formatted_program-e3ce1c.c:7:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
c;
^
formatted_program-e3ce1c.c:8:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
d() {
^
formatted_program-e3ce1c.c:14:34: warning: implicit truncation from 'int' to bit-field changes value from 27563224 to -5991208 [-Wbitfield-constant-conversion]
struct a f[6][1] = {81298, 27563224};
^~~~~~~~
formatted_program-e3ce1c.c:20:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {}
^
clang-14: /tmp/tmp.X2xbVSfcay-clang-builder/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp:509: void llvm::DwarfExpression::addExpression(llvm::DIExpressionCursor&&, llvm::function_ref<bool(unsigned int, llvm::DIExpressionCursor&)>): Assertion `SizeInBits >= OffsetInBits - FragmentOffset && "size underflow"' 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-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name formatted_program-e3ce1c.c -mrelocation-model static -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fcoverage-compilation-dir=/home/tlwang/clang_crashes/crash1 -resource-dir /scratch/software/clang-trunk/lib/clang/14.0.0 -internal-isystem /scratch/software/clang-trunk/lib/clang/14.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 -O2 -fdebug-compilation-dir=/home/tlwang/clang_crashes/crash1 -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/formatted_program-e3ce1c-799385.o -x c formatted_program-e3ce1c.c

  1. parser at end of file
  2. Code generation
  3. Running pass 'Function Pass Manager' on module 'formatted_program-e3ce1c.c'.
  4. Running pass 'X86 Assembly Printer' on function '@d'
    #​0 0x000055ec3e3ebdb4 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
    #​1 0x000055ec3e3e94ce SignalHandler(int) Signals.cpp:0:0
    #​2 0x00007faac66633c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
    #​3 0x00007faac610218b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
    #​4 0x00007faac60e1859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7
    #​5 0x00007faac60e1729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8
    #​6 0x00007faac60e1729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34
    #​7 0x00007faac60f2f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
    #​8 0x000055ec3f2080b0 llvm::DwarfExpression::addExpression(llvm::DIExpressionCursor&&, llvm::function_ref<bool (unsigned int, llvm::DIExpressionCursor&)>) (/scratch/software/clang-trunk/bin/clang-14+0x48440b0)
    #​9 0x000055ec3f267b6b llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&, bool) (/scratch/software/clang-trunk/bin/clang-14+0x48a3b6b)
    #​10 0x000055ec3f268617 llvm::DwarfCompileUnit::constructVariableDIE(llvm::DbgVariable&, llvm::LexicalScope const&, llvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48a4617)
    #​11 0x000055ec3f26f9a9 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48ab9a9)
    #​12 0x000055ec3f271aa8 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48adaa8)
    #​13 0x000055ec3f26fbc3 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48abbc3)
    #​14 0x000055ec3f271aa8 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48adaa8)
    #​15 0x000055ec3f26fbc3 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48abbc3)
    #​16 0x000055ec3f271aa8 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48adaa8)
    #​17 0x000055ec3f26fbc3 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48abbc3)
    #​18 0x000055ec3f271aa8 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48adaa8)
    #​19 0x000055ec3f26fbc3 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48abbc3)
    #​20 0x000055ec3f271aa8 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48adaa8)
    #​21 0x000055ec3f26fbc3 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48abbc3)
    #​22 0x000055ec3f271aa8 llvm::DwarfCompileUnit::constructScopeDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&) (/scratch/software/clang-trunk/bin/clang-14+0x48adaa8)
    #​23 0x000055ec3f26fbc3 llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*, llvm::SmallVectorImplllvm::DIE*&, bool*) (/scratch/software/clang-trunk/bin/clang-14+0x48abbc3)
    #​24 0x000055ec3f27119a llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*, llvm::DIE&) (/scratch/software/clang-trunk/bin/clang-14+0x48ad19a)
    #​25 0x000055ec3f271807 llvm::DwarfCompileUnit::constructSubprogramScopeDIE(llvm::DISubprogram const*, llvm::LexicalScope*) (/scratch/software/clang-trunk/bin/clang-14+0x48ad807)
    #​26 0x000055ec3f2011a3 llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) (/scratch/software/clang-trunk/bin/clang-14+0x483d1a3)
    #​27 0x000055ec3f1ccc32 llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) (/scratch/software/clang-trunk/bin/clang-14+0x4808c32)
    #​28 0x000055ec3f1c8102 llvm::AsmPrinter::emitFunctionBody() (/scratch/software/clang-trunk/bin/clang-14+0x4804102)
    #​29 0x000055ec3cd43f06 llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/scratch/software/clang-trunk/bin/clang-14+0x237ff06)
    #​30 0x000055ec3d57b4f8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/scratch/software/clang-trunk/bin/clang-14+0x2bb74f8)
    #​31 0x000055ec3da76905 llvm::FPPassManager::runOnFunction(llvm::Function&) (/scratch/software/clang-trunk/bin/clang-14+0x30b2905)
    #​32 0x000055ec3da76b49 llvm::FPPassManager::runOnModule(llvm::Module&) (/scratch/software/clang-trunk/bin/clang-14+0x30b2b49)
    #​33 0x000055ec3da77c32 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/scratch/software/clang-trunk/bin/clang-14+0x30b3c32)
    #​34 0x000055ec3e741f63 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_deletellvm::raw_pwrite_stream >) (/scratch/software/clang-trunk/bin/clang-14+0x3d7df63)
    #​35 0x000055ec3f5e8493 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch/software/clang-trunk/bin/clang-14+0x4c24493)
    #​36 0x000055ec4069d829 clang::ParseAST(clang::Sema&, bool, bool) (/scratch/software/clang-trunk/bin/clang-14+0x5cd9829)
    #​37 0x000055ec3f5e6e48 clang::CodeGenAction::ExecuteAction() (/scratch/software/clang-trunk/bin/clang-14+0x4c22e48)
    #​38 0x000055ec3ee5bfe9 clang::FrontendAction::Execute() (/scratch/software/clang-trunk/bin/clang-14+0x4497fe9)
    #​39 0x000055ec3edeadde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/software/clang-trunk/bin/clang-14+0x4426dde)
    #​40 0x000055ec3ef3c523 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/software/clang-trunk/bin/clang-14+0x4578523)
    #​41 0x000055ec3bb8058d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/software/clang-trunk/bin/clang-14+0x11bc58d)
    #​42 0x000055ec3bb7c998 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
    #​43 0x000055ec3baa4099 main (/scratch/software/clang-trunk/bin/clang-14+0x10e0099)
    #​44 0x00007faac60e30b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
    #​45 0x000055ec3bb7c50e _start (/scratch/software/clang-trunk/bin/clang-14+0x11b850e)
    clang-14: error: unable to execute command: Aborted (core dumped)
    clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
    clang version 14.0.0 (https://github.com/llvm/llvm-project.git 91434d4)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/cnsun/usr/bin
    clang-14: note: diagnostic msg:

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/formatted_program-e3ce1c-d1a9bf.c
clang-14: note: diagnostic msg: /tmp/formatted_program-e3ce1c-d1a9bf.sh
clang-14: note: diagnostic msg:


@dwblaikie
Copy link
Collaborator

llvm/llvm-bugzilla-archive#52584 might be the same or related.

@dwblaikie
Copy link
Collaborator

mentioned in issue llvm/llvm-bugzilla-archive#52584

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@rickyz
Copy link
Member

rickyz commented Dec 17, 2021

I don't seem to have access to close this issue, but it can probably be closed as a duplicate of #51926 (which has been fixed by c7c84b9).

@fhahn
Copy link
Contributor

fhahn commented Dec 17, 2021

I don't seem to have access to close this issue, but it can probably be closed as a duplicate of #51926 (which has been fixed by c7c84b9).

Thanks for the heads-up, this looks fixed indeed: https://clang.godbolt.org/z/v68od1fhG

@theo-lw please re-open or file a new issue with an updated reproducer if you can still reproduce this.

@fhahn fhahn closed this as completed Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:codegen
Projects
None yet
Development

No branches or pull requests

4 participants