[LLVMbugs] [Bug 12140] New: struct packing causing crashes

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 29 14:10:46 PST 2012


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

             Bug #: 12140
           Summary: struct packing causing crashes
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: tim.prime at citrix.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


$ svn info
Path: .
Working Copy Root Path: /usr/home/timpr/workspace/llvm
URL: http://llvm.org/svn/llvm-project/llvm/trunk
Repository Root: http://llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 151742
Node Kind: directory
Schedule: normal
Last Changed Author: hfinkel
Last Changed Rev: 151732
Last Changed Date: 2012-02-29 08:43:11 -0800 (Wed, 29 Feb 2012)

$ gcc -v
Using built-in specs.
Target: i386-portbld-freebsd6.3
Configured with: ./../gcc-4.2-20090325/configure --disable-nls
--libdir=/usr/local/lib/gcc42 --libexecdir=/usr/local/libexec/gcc42
--program-suffix=42 --with-as=/usr/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc42/include/c++/ --with-ld=/usr/bin/ld
--with-libiconv-prefix=/usr/local --with-system-zlib --prefix=/usr/local
--mandir=/usr/local/man --infodir=/usr/local/info/gcc42 i386-portbld-freebsd6.3
Thread model: posix
gcc version 4.2.5 20090325 (prerelease) [FreeBSD Ports Collection]

During the build, I get these warnings (22 times each):
/usr/home/timpr/workspace/llvm/include/llvm/Support/Endian.h:39: warning:
#pragma pack(push[, id], <n>) is not supported on this target
/usr/home/timpr/workspace/llvm/include/llvm/Support/Endian.h:46: warning:
#pragma pack(pop[, id], <n>) is not supported on this target

While running the test suite,
  Expected Passes    : 5465
  Expected Failures  : 49
  Unsupported Tests  : 13
  Unexpected Failures: 287

Most of the failures are crashes.  For example,
$ Debug+Asserts/bin/llvm-dis <purecse.opt > purecse.dis
Stack dump:
0.    Program arguments: Debug+Asserts/bin/llvm-dis 
Segmentation fault: 11 (core dumped)


(gdb) bt
#0  0x0813f276 in llvm::Module::getValueSymbolTable (this=0x228b8000)
    at Module.h:504
#1  0x08181cce in getSymTab (V=0x8243580, ST=@0xbfbfe3c8)
    at /usr/home/timpr/workspace/llvm/lib/VMCore/Value.cpp:151
#2  0x08183400 in llvm::Value::setName (this=0x8243580, NewName=@0xbfbfe6ba)
    at /usr/home/timpr/workspace/llvm/lib/VMCore/Value.cpp:188
#3  0x0805d21a in llvm::BitcodeReader::ParseValueSymbolTable (this=0x8236000)
    at /usr/home/timpr/workspace/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:796
#4  0x080683ec in llvm::BitcodeReader::ParseModule (this=0x8236000, 
    Resume=false)
    at /usr/home/timpr/workspace/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1478
#5  0x0806a228 in llvm::BitcodeReader::ParseBitcodeInto (this=0x8236000, 
    M=0x8228b80)
    at /usr/home/timpr/workspace/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1754
#6  0x0806a33b in llvm::getStreamedBitcodeModule (name=@0xbfbfeb74, 
    streamer=0x8229370, Context=@0x82292f0, ErrMsg=0xbfbfeb88)
    at /usr/home/timpr/workspace/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:2907
#7  0x0804f7a0 in main (argc=1, argv=0xbfbfec30)
    at /usr/home/timpr/workspace/llvm/tools/llvm-dis/llvm-dis.cpp:139
(gdb) p GV->Parent
$4 = (class llvm::Module *) 0x8228b80

Notice the 3 bytes of similarity.

I have run experiments by altering Endian.h, removing the unsupported
pack(push) and replacing pack(pop) with pack().  Make check comes out clean,
  Expected Passes    : 5790
  Expected Failures  : 49
  Unsupported Tests  : 13

At this point, the problem is fairly well understood.  Not sure what the proper
fix is.

Would prefer #pragma pack to be left out of header files.  This took a
relatively small incompatibility and amplified it into a serious and confusing
problem.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list