[LLVMbugs] [Bug 3046] New: __builtin__CFStringMakeConstantString crashes on 64-bit systems

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Nov 11 16:10:31 PST 2008


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

           Summary: __builtin__CFStringMakeConstantString crashes on 64-bit
                    systems
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sebastian.redl at getdesigned.at
                CC: llvmbugs at cs.uiuc.edu


The layout of the internal CFString struct looks something like this:
struct {
  void *ClassType;
  unsigned int Flags;
  const char *Data;
  long Length;
}

CodeGenModule::GetAddrOfConstantCFString happily assumes that this is correct
for the LLVM Type and thus builds the corresponding 4-element vector for the
initializer.

However, padding bytes are actual members on the LLVM level. On 64-bit systems,
the 32-bit Flags member is padded so that the 64-bit Data pointer is aligned.
The actual layout of the struct on the LLVM level thus looks like this:

struct {
  void *ClassType;
  unsigned int Flags;
  char padding1;
  char padding2;
  char padding3;
  char padding4;
  const char *Data;
  long Length;
}

The function then calls llvm::ConstantStruct::get with the 4-element
initializer and the 8-element structure, leading to an assertion being
triggered in the ConstantStruct constructor in llvm/lib/VMCore/Constants.cpp on
line 411.

The clang test CodeGen/cfstring.c triggers this bug.


-- 
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