[LLVMbugs] [Bug 15593] New: initializaing allocated multirank arrays causes heap corruption

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 25 14:42:09 PDT 2013


            Bug ID: 15593
           Summary: initializaing allocated multirank arrays causes heap
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: phernost at yahoo.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

first an example, build and run with or without optimizations:

int main(int argc, char *argv[])
    auto a = new int[3][2]; // ok
    int s = 3;  // odd numbers of s greater than 1 cause corruption
    auto b = new int[s][2]{}; // corrupted
    auto c = new int[4]; // crash
    delete[] c; // never gets here
    delete[] b; // never gets here
    delete[] a; // never gets here
    return 0;

It's is possible to "delete[] b" and delay the crash. I assume it's because the
next allocation that fits into the "b" space is ok, but the heap after "b" is
corrupt.  Any "malloc" will crash if that allocation will occur after "b".

Built using gcc(4.7.2-1) and the same standard library, libstdc++6 (4.7.2-22),
doesn't crash.

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/20130325/634df100/attachment.html>

More information about the llvm-bugs mailing list