www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8301] New: Exception not caught when a big array is allocated

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8301

           Summary: Exception not caught when a big array is allocated
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: mp81ss rambler.ru



import std.stdio;

void main()
{
    try {
        byte[] big_buf = new byte[4294967295];
        writeln("Allocated");
    }
    catch(Exception) {
        writeln("never displayed");
    }
}


The string "never displayed" is never displayed and the client crushes with
object.Error: Access Violation.

Same if instead of (2^32 -1) you put -1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 26 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8301


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch
            Summary|Exception not caught when a |Access violation when a big
                   |big array is allocated      |array is allocated
           Severity|major                       |normal



It is to be expected that catch(Exception) will not catch an Error, because
Exception is not a super class of Error.

However, the code snippet should throw OutOfMemoryError. There should not be an
access violation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 26 2012