I have run into a problem with a page allocator that I cannot wrap my head around. The program is run on Ubuntu 14.04 x86_64 and the g++ –version output says “g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2”.
My issue is that sometimes, I receive the same pointer from a mmap() call that I already have received from earlier call without that previous pointer ever having been mmunmap():ed. In one debugging sessions for example I successfully allocated 2097152 bytes and got the pointer 0x7fffaa398000, and then some time later with a bunch other allocations in between I successfully allocated 12288 bytes for the very same pointer, 0x7fffaa398000. The allocator then proceeds to assert because book keeping notices this double entry.
The call looks like this:
void *p = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
Is it possible for the pointer to get deallocated in some other way other than munmap()?