mc_translate.c: enable further uses of DLexpensive for scalar EQ/NE comparisons
[valgrind.git] / none / tests / amd64 / nibz_bennee_mmap.c
blobaa0376889e3a9a014ec2b630b03e293b67edc247
2 /* Test for aspacem bug reported by Alex Bennee, reported on users
3 list around 9 Aug 06, resulting in
5 > > --1515:0:aspacem Valgrind: FATAL: aspacem assertion failed:
6 > > --1515:0:aspacem holeEnd <= aspacem_maxAddr
7 > > --1515:0:aspacem at m_aspacemgr/aspacemgr.c:1998
8 > > (vgPlain_am_get_advisory)
9 > > --1515:0:aspacem Exiting now.
11 TomH writes:
13 > I think the problem here is that you've done an mmap (either fixed or
14 > hinted) above aspacem_maxAddr and then munmaped it which leaves you
15 > with a free segment above aspacem_maxAddr.
17 The sequence seems to be that you have to allocate memory somewhere
18 above aspacem_maxAddr, then free it, then do another hinted
19 allocation that is above aspacem_maxAddr but which can't be done
20 due to the memory already being in use. This program will reproduce
21 it.
23 On investigation: the problem was the munmap returns its space in
24 the form of SkFree even though the space above aspacem_maxAddr is
25 supposed to be SkResvn. This is now fixed.
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include "tests/sys_mman.h"
32 int main(int argc, char **argv)
34 void *p;
35 if ((p = mmap((void*)0x1F7F100000, 4096, PROT_READ|PROT_WRITE,
36 MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0)) == (void *)-1)
38 perror("mmap");
39 exit(1);
41 if (munmap(p, 4096) < 0)
43 perror("munmap");
44 exit(1);
46 if ((p = mmap((void*)0x1F7F101000, 4096, PROT_READ,
47 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)) == (void *)-1)
49 perror("mmap");
50 exit(1);
52 if ((p = mmap((void*)0x1F7F101000, 4096, PROT_READ,
53 MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)) == (void *)-1)
55 perror("mmap");
56 exit(1);
59 printf("made it through alive!\n");
60 exit(0);