[LLVMbugs] [Bug 22300] New: clang crashes on valid code at -O1 and above with -g enabled on x86_64-linux-gnu (in 32-bit mode)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 22 14:03:09 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22300

            Bug ID: 22300
           Summary: clang crashes on valid code at -O1 and above with -g
                    enabled on x86_64-linux-gnu (in 32-bit mode)
           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: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The current clang trunk crashes when compiling the following test case at -O1
and above with -g enabled in the 32-bit mode (but not in 64-bit mode). 

This is a regression from clang 3.5.x. 

$ clang-trunk -v
clang version 3.7.0 (trunk 226698)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.1
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.6
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.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ 
$ clang-trunk -m32 -O1 -c small.c
$ clang-trunk -m64 -O1 -g -c small.c
$ clang-3.5.0 -m32 -O1 -g -c small.c
$ 
$ clang-trunk -m32 -O1 -g -c small.c
clang: /tmp/llvm/lib/CodeGen/TargetRegisterInfo.cpp:113: const
llvm::TargetRegisterClass
*llvm::TargetRegisterInfo::getMinimalPhysRegClass(unsigned int, llvm::MVT)
const: Assertion `isPhysicalRegister(reg) && "reg must be a physical register"'
failed.
#0 0x2a430b8 llvm::sys::PrintStackTrace(_IO_FILE*)
(/usr/local/clang-trunk/bin/clang+0x2a430b8)
#1 0x2a4460b (/usr/local/clang-trunk/bin/clang+0x2a4460b)
#2 0x7f9f13f4ecb0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0xfcb0)
#3 0x7f9f12d6d0d5 gsignal
/build/buildd/eglibc-2.15/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:64:0
#4 0x7f9f12d7083b abort /build/buildd/eglibc-2.15/stdlib/abort.c:93:0
#5 0x7f9f12d65d9e __assert_fail_base
/build/buildd/eglibc-2.15/assert/assert.c:55:0
#6 0x7f9f12d65e42 (/lib/x86_64-linux-gnu/libc.so.6+0x2ee42)
#7 0x243027d (/usr/local/clang-trunk/bin/clang+0x243027d)
#8 0x2272724 llvm::DwarfExpression::AddMachineRegPiece(unsigned int, unsigned
int, unsigned int) (/usr/local/clang-trunk/bin/clang+0x2272724)
#9 0x22732a4 llvm::DwarfExpression::AddMachineRegExpression(llvm::DIExpression,
unsigned int, unsigned int) (/usr/local/clang-trunk/bin/clang+0x22732a4)
#10 0x229a3c0 llvm::DwarfCompileUnit::addComplexAddress(llvm::DbgVariable
const&, llvm::DIE&, llvm::dwarf::Attribute, llvm::MachineLocation const&)
(/usr/local/clang-trunk/bin/clang+0x229a3c0)
#11 0x2298c27 llvm::DwarfCompileUnit::addVariableAddress(llvm::DbgVariable
const&, llvm::DIE&, llvm::MachineLocation)
(/usr/local/clang-trunk/bin/clang+0x2298c27)
#12 0x22988fa
llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&,
bool) (/usr/local/clang-trunk/bin/clang+0x22988fa)
#13 0x22975ad
llvm::DwarfCompileUnit::createScopeChildrenDIE(llvm::LexicalScope*,
llvm::SmallVectorImpl<std::unique_ptr<llvm::DIE, std::default_delete<llvm::DIE>
> >&, unsigned int*) (/usr/local/clang-trunk/bin/clang+0x22975ad)
#14 0x2299256
llvm::DwarfCompileUnit::createAndAddScopeChildren(llvm::LexicalScope*,
llvm::DIE&) (/usr/local/clang-trunk/bin/clang+0x2299256)
#15 0x2298fb8
llvm::DwarfCompileUnit::constructSubprogramScopeDIE(llvm::LexicalScope*)
(/usr/local/clang-trunk/bin/clang+0x2298fb8)
#16 0x22631a7 llvm::DwarfDebug::endFunction(llvm::MachineFunction const*)
(/usr/local/clang-trunk/bin/clang+0x22631a7)
#17 0x22495ae llvm::AsmPrinter::EmitFunctionBody()
(/usr/local/clang-trunk/bin/clang+0x22495ae)
#18 0x1f7b175 (/usr/local/clang-trunk/bin/clang+0x1f7b175)
#19 0x233519c llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x233519c)
#20 0x29c3281 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x29c3281)
#21 0x29c34bb llvm::FPPassManager::runOnModule(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x29c34bb)
#22 0x29c3995 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x29c3995)
#23 0x9145fd clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_ostream*) (/usr/local/clang-trunk/bin/clang+0x9145fd)
#24 0x908cf5 (/usr/local/clang-trunk/bin/clang+0x908cf5)
#25 0xaf9d43 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xaf9d43)
#26 0x70a4ee clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0x70a4ee)
#27 0x6dd00c clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0x6dd00c)
#28 0x6be83a clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0x6be83a)
#29 0x6b53c2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
(/usr/local/clang-trunk/bin/clang+0x6b53c2)
#30 0x6bce9b main (/usr/local/clang-trunk/bin/clang+0x6bce9b)
#31 0x7f9f12d5876d __libc_start_main
/build/buildd/eglibc-2.15/csu/libc-start.c:258:0
#32 0x6b5029 _start (/usr/local/clang-trunk/bin/clang+0x6b5029)
Stack dump:
0.    Program arguments: /usr/local/clang-trunk/bin/clang -cc1 -triple
i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name small.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4
-target-linker-version 2.22 -momit-leaf-frame-pointer -g -dwarf-column-info
-coverage-file
/data2/c-hunter-results/C/trans-bugs/REDUCED/20150121-clang-m32-m64-O1-O2-O3-Os-build-test18356/small.c
-resource-dir /usr/local/clang-trunk/bin/../lib/clang/3.7.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.7.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -O1 -fdebug-compilation-dir
/data2/c-hunter-results/C/trans-bugs/REDUCED/20150121-clang-m32-m64-O1-O2-O3-Os-build-test18356
-ferror-limit 19 -fmessage-length 117 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c small.c 
1.    <eof> parser at end of file
2.    Code generation
3.    Running pass 'Function Pass Manager' on module 'small.c'.
4.    Running pass 'X86 Assembly / Object Emitter' on function '@fn1'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.0 (trunk 226698)
Target: i386-unknown-linux-gnu
Thread model: posix
clang: 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: note: diagnostic msg: 
********************

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

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


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


int *a, b, c, d, e, *f;

void
fn1 ()
{
  int *g, **h[2] = { &g, 0 };
  for (; b; b++)
    {
      int **i = &g;
      for (; d; d--)
    for (; c < 10; c++)
      {
        for (; e < 0; e++)
          f = a;
        i = 0;
      }

      if (!i) 
    __builtin_abort(); 
    }
}

-- 
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/20150122/5050947b/attachment.html>


More information about the llvm-bugs mailing list