Mercurial > projects > dstress
annotate run/m/memory_management_07_A.d @ 1579:1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
<david@acz.org>
2007-11-12
http://d.puremagic.com/issues/show_bug.cgi?id=1666
author | thomask |
---|---|
date | Fri, 22 Feb 2008 07:54:04 +0000 |
parents | |
children |
rev | line source |
---|---|
1579
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
1 // $HeadURL$ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
2 // $Date$ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
3 // $Author$ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
4 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
5 // @author@ <david@acz.org> |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
6 // @date@ 2007-11-12 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
7 // @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=1666 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
8 // @desc@ [Issue 1666] New: 64-bit gdc programs cannot allocate large arrays |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
9 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
10 module dstress.run.m.memory_management_07_A; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
11 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
12 int main(char[][] args){ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
13 ubyte x[]; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
14 size_t len = size_t.max - (size_t.max / 32); |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
15 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
16 try{ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
17 x.length = len; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
18 }catch(Exception e){ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
19 // "out of memory" Exception |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
20 return 0; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
21 } |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
22 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
23 // a LOT of memory (maybe someone cheated *g*) |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
24 if(len != x.length){ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
25 assert(0); |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
26 } |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
27 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
28 // try to defeat "smart" cheaters |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
29 size_t step = 4096 - args.length; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
30 for(size_t i = 0; i < len; i += step){ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
31 x[i] = i & 0xFF; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
32 } |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
33 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
34 step = 4096 - ((args[0].length / 1000 + 1) % 13); |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
35 for(size_t i = 0; i < len; i += step){ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
36 if((i & 0xFF) != x[i]){ |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
37 assert(0); |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
38 } |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
39 } |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
40 |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
41 return 0; |
1802d6b67634
[Issue 1666] New: 64-bit gdc programs cannot allocate large arrays
thomask
parents:
diff
changeset
|
42 } |