# HG changeset patch # User thomask # Date 1203666844 0 # Node ID 1802d6b676344a7b0c675effa2a1b83588e12122 # Parent 10a4a6037695ef5c84463662b2fb89c6adcedfef [Issue 1666] New: 64-bit gdc programs cannot allocate large arrays 2007-11-12 http://d.puremagic.com/issues/show_bug.cgi?id=1666 diff -r 10a4a6037695 -r 1802d6b67634 run/m/memory_management_07_A.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/m/memory_management_07_A.d Fri Feb 22 07:54:04 2008 +0000 @@ -0,0 +1,42 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ +// @date@ 2007-11-12 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1666 +// @desc@ [Issue 1666] New: 64-bit gdc programs cannot allocate large arrays + +module dstress.run.m.memory_management_07_A; + +int main(char[][] args){ + ubyte x[]; + size_t len = size_t.max - (size_t.max / 32); + + try{ + x.length = len; + }catch(Exception e){ + // "out of memory" Exception + return 0; + } + + // a LOT of memory (maybe someone cheated *g*) + if(len != x.length){ + assert(0); + } + + // try to defeat "smart" cheaters + size_t step = 4096 - args.length; + for(size_t i = 0; i < len; i += step){ + x[i] = i & 0xFF; + } + + step = 4096 - ((args[0].length / 1000 + 1) % 13); + for(size_t i = 0; i < len; i += step){ + if((i & 0xFF) != x[i]){ + assert(0); + } + } + + return 0; +} diff -r 10a4a6037695 -r 1802d6b67634 run/m/memory_management_07_B.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/m/memory_management_07_B.d Fri Feb 22 07:54:04 2008 +0000 @@ -0,0 +1,41 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ +// @date@ 2007-11-12 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1666 +// @desc@ [Issue 1666] New: 64-bit gdc programs cannot allocate large arrays + +module dstress.run.m.memory_management_07_B; + +int main(char[][] args){ + ubyte x[]; + size_t len = 1 << 29; + + try{ + x.length = len; + }catch(Exception e){ + // "out of memory" Exception + return 0; + } + + if(len != x.length){ + assert(0); + } + + // try to defeat "smart" cheaters + size_t step = 4096 - args.length; + for(size_t i = 0; i < len; i += step){ + x[i] = i & 0xFF; + } + + step = 4096 - ((args[0].length / 1000 + 1) % 13); + for(size_t i = 0; i < len; i += step){ + if((i & 0xFF) != x[i]){ + assert(0); + } + } + + return 0; +}