[llvm-bugs] [Bug 26347] New: clang crashes on valid code (with packed struct) at -Os and above on x86_64-linux-gnu (in 32-bit mode)

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 27 17:10:35 PST 2016


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

            Bug ID: 26347
           Summary: clang crashes on valid code (with packed struct) at
                    -Os and above 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: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following test case on
x86_64-linux-gnu at -Os and above in the 32-bit mode (but not in the 64-bit
mode).

This is a regression from 3.7.x.


$ clang-trunk -v
clang version 3.9.0 (trunk 258783)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
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.4
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-trunk -m32 -O1 small.c; ./a.out
$ clang-3.7.0 -m32 -Os small.c; ./a.out
$ clang-trunk -m64 -Os small.c; ./a.out
$ 
$ clang-trunk -m32 -Os small.c
clang: /tmp/llvm/lib/Analysis/ValueTracking.cpp:1627: void
computeKnownBits(llvm::Value*, llvm::APInt&, llvm::APInt&, unsigned int, const
{anonymous}::Query&): Assertion
`(Q.DL.getTypeSizeInBits(V->getType()->getScalarType()) == BitWidth) &&
(!V->getType()->isIntOrIntVectorTy() || V->getType()->getScalarSizeInBits() ==
BitWidth) && KnownZero.getBitWidth() == BitWidth && KnownOne.getBitWidth() ==
BitWidth && "V, KnownOne and KnownZero should have same BitWidth"' failed.
#0 0x0000000003255885 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang+0x3255885)
#1 0x0000000003253816 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang+0x3253816)
#2 0x0000000003253a34 (/usr/local/clang-trunk/bin/clang+0x3253a34)
#3 0x00007f5ceb244340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f5cea252cc9 gsignal
/build/buildd/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f5cea2560d8 abort /build/buildd/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f5cea24bb86 __assert_fail_base
/build/buildd/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f5cea24bc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000002fd262c (/usr/local/clang-trunk/bin/clang+0x2fd262c)
#9 0x0000000000a31345 _init (/usr/local/clang-trunk/bin/clang+0xa31345)
#10 0x0000000002fd27b0 (/usr/local/clang-trunk/bin/clang+0x2fd27b0)
#11 0x0000000002fd65fc (/usr/local/clang-trunk/bin/clang+0x2fd65fc)
#12 0x0000000002fd6a6a (/usr/local/clang-trunk/bin/clang+0x2fd6a6a)
#13 0x0000000002fd6b95 (/usr/local/clang-trunk/bin/clang+0x2fd6b95)
#14 0x0000000002fd6f9f llvm::ComputeNumSignBits(llvm::Value*, llvm::DataLayout
const&, unsigned int, llvm::AssumptionCache*, llvm::Instruction const*,
llvm::DominatorTree const*) (/usr/local/clang-trunk/bin/clang+0x2fd6f9f)
#15 0x0000000002cfe1ef (/usr/local/clang-trunk/bin/clang+0x2cfe1ef)
#16 0x0000000002ca3f26 (/usr/local/clang-trunk/bin/clang+0x2ca3f26)
#17 0x0000000002ca5040 (/usr/local/clang-trunk/bin/clang+0x2ca5040)
#18 0x0000000002ca5a00 (/usr/local/clang-trunk/bin/clang+0x2ca5a00)
#19 0x00000000031c4e33 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/usr/local/clang-trunk/bin/clang+0x31c4e33)
#20 0x00000000031c547b llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/usr/local/clang-trunk/bin/clang+0x31c547b)
#21 0x0000000000d0167a clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*) (/usr/local/clang-trunk/bin/clang+0xd0167a)
#22 0x0000000000cdf0c7 (/usr/local/clang-trunk/bin/clang+0xcdf0c7)
#23 0x0000000000f2f21d clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang+0xf2f21d)
#24 0x0000000000cdf1be clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang+0xcdf1be)
#25 0x0000000000adeb06 clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang+0xadeb06)
#26 0x0000000000ab5eb6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang+0xab5eb6)
#27 0x0000000000a98fc3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang+0xa98fc3)
#28 0x0000000000a902d0 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang+0xa902d0)
#29 0x0000000000a516ed main (/usr/local/clang-trunk/bin/clang+0xa516ed)
#30 0x00007f5cea23dec5 __libc_start_main
/build/buildd/eglibc-2.19/csu/libc-start.c:321:0
#31 0x0000000000a8ecf8 _start (/usr/local/clang-trunk/bin/clang+0xa8ecf8)
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.24 -momit-leaf-frame-pointer -dwarf-column-info
-debugger-tuning=gdb -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.9.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -Os -fdebug-compilation-dir
/home/su/20160127-clang-trunk-m64-Os-build-084902 -ferror-limit 19
-fmessage-length 88 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -o /tmp/small-5368dd.o -x c
small.c 
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Function Pass Manager' on module 'small.c'.
4.    Running pass 'Combine redundant instructions' 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.9.0 (trunk 258783)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
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-79f9e5.c
clang: note: diagnostic msg: /tmp/small-79f9e5.sh
clang: note: diagnostic msg: 

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


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


int printf (const char *, ...);

#pragma pack(1)
struct S
{
  int f0:29;
  int f1:26;
  int:13;
};

int a;

void
fn1 ()
{
  struct S b;
  for (; a;)
    {
      int c = b.f0 - b.f1;
      int d = a = a + c;
      printf ("0");
      b.f1 = d;
      b.f0 = c;
    }
}

int
main ()
{
  fn1 (); 
  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/20160128/cf59bc1f/attachment.html>


More information about the llvm-bugs mailing list