Hi all,
Does anybody know if/how I can obtain a
virtual memory mapping that grows automatically on memory accesses that
fall in the page just below the existing mapping, just like stacks do?
On linux, stacks have this behavior, both "default" processes' stacks
and stacks allocated for pthreads. It even works for stacks that I've
allocated myself for pthreads (via mmap and pthread_attr_setstack). But I
cannot get it to work for a mapping that is not used as a pthread
stack; I get a SIGSEGV as soon as I step out of the page I've mapped
with mmap. I've found the MAP_GROWSDOWN flag for mmap that is supposed
to do this (at list some documentation implies it does it on IA-64), but
on my AMD64 machine it doesn't work. Other documentation seems to
suggest that MAP_GROWSDOWN is simply a hint to the kernel to try to
return a region that has free space below, which would mean that it
can't be combined with MAP_FIXED, which asks for a mapping at a fixed
address, which is what I want (and anyway, it doesn't seem to work even
if I don't use MAP_FIXED).
Any idea about this?
Thanks,
- Andrei