Bug 8301 – Access violation when a big array is allocated

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-26T07:08:00Z
Last change time
2013-11-28T18:08:27Z
Keywords
pull
Assigned to
nobody
Creator
mp81ss

Comments

Comment #0 by mp81ss — 2012-06-26T07:08:59Z
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.
Comment #1 by timon.gehr — 2012-06-26T08:35:49Z
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.
Comment #2 by yebblies — 2013-11-26T08:44:36Z
Comment #3 by github-bugzilla — 2013-11-28T09:00:50Z
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/659a40baabe1cc6a1f478d472a69810600b68646 Fix Issue 8301 - Access violation when a big array is allocated Check that adding array padding doesn't cause overflow https://github.com/D-Programming-Language/druntime/commit/c38f3bad4a73402da2609a87c058a28e5ff234f3 Merge pull request #673 from yebblies/issue8301 Issue 8301 - Access violation when a big array is allocated