[LLVMbugs] [Bug 4925] New: llc crash when a const struct includes a zero-length member

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Sep 8 06:14:45 PDT 2009


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

           Summary: llc crash when a const struct includes a zero-length
                    member
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: compile-fail
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: kennethuil at gmail.com
                CC: llvmbugs at cs.uiuc.edu


When I run llc on the (assembled version of) the following code on Linux x86:

%testType = type {i32, [0 x i32], i32}

define i32 @main() {
 %1 = alloca %testType

 store %testType {i32 1, [0 x i32] zeroinitializer, i32 2}, %testType* %1
 ret i32 0
}

llc crashes with a segmentation fault.  It happens in the 2.5 release
version and in the version I pulled from svn trunk about two days
ago.

The trouble starts in SelectionDAGLowering::getValue(const Value* V),
within the if (isa<ConstantStruct>(C) || isa<ConstantArray>(C)) check,
where the zero-length member (which can be either a zero-length array
or an empty struct) causes getValue(*OI).getNode() to return NULL.
The segfault occurs when this null pointer is used as the instance
pointer for SDNode::getNumValues().  It doesn't matter whether the
zero-length member appears at the beginning, the end, or somewhere in
the middle.

A simple null check on the result of getValue(*OI).getNode() clears up
the segfault and makes my larger test program run properly after
llc'ing and assembling (not surprising, since leaving out the
zero-length member leaves the result of the store unchanged).


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