blob: f8f3fca1a344637152cc2896785b454429af36f7 [file] [log] [blame]
nethercote57e36b32004-07-10 14:56:28 +00001#include <stdlib.h>
2#include <sys/mman.h>
3#include <stdio.h>
4
5int main(void)
6{
7 void *p;
8
9 int size = 2 * 1023 * 1024 * 1024; // just under 2^31 (2GB)
10
11 fprintf(stderr, "Attempting too-big malloc()...\n");
12 p = malloc(size); // way too big!
13 if (p)
14 fprintf(stderr, "huge malloc() succeeded??\n");
15
16 fprintf(stderr, "Attempting too-big mmap()...\n");
17 p = mmap( 0, size, PROT_READ|PROT_WRITE|PROT_EXEC,
18 MAP_PRIVATE|MAP_ANON, -1, 0 );
19 if (-1 != (int)p)
20 fprintf(stderr, "huge mmap() succeeded??\n");
21
22 return 0;
23}