[LLVMbugs] [Bug 4590] New: Infinite loop in ConvertToPacked in llvm-gcc

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jul 19 21:49:39 PDT 2009


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

           Summary: Infinite loop in ConvertToPacked in llvm-gcc
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: Nathan.Keynes at sun.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=3226)
 --> (http://llvm.org/bugs/attachment.cgi?id=3226)
Test case extracted from linux drivers/usb/gadget/ether.c

Attached test case loops forever in ConvertToPacked (llvm-convert.cpp) trying
to add ever-increasing amounts of padding to the packed structure. This looks
like a regression as I can't reproduce with 2.5.

It looks like it's getting confused by the iMACAddress field, which is declared
in the structure but missing from the constant - it actually works properly if
either the iMACAddress field is removed entirely, or if an explicit value is
added for the field in the constant decl.

Possible patch:
Index: gcc/llvm-convert.cpp
===================================================================
--- gcc/llvm-convert.cpp        (revision 76305)
+++ gcc/llvm-convert.cpp        (working copy)
@@ -7368,6 +7368,7 @@
       PadTy = Context.getArrayType(PadTy, AlignedEltOffs-EltOffs);
     ResultElts.insert(ResultElts.begin()+i,
                       Context.getNullValue(PadTy));
+    EltOffs += TD.getTypeAllocSize(PadTy);
     ++e;  // One extra element to scan.
   }

This fixes the infinite loop, and produces the correct output for this testcase
and a few similar cases I've tried. I'm not 100% certain there aren't other
issues around this though.


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