Re: mmap and stacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Apr 20, 2010 at 2:47 AM, Andrei Matei <andreimatei1@xxxxxxxxx> wrote:
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?

Just a curious question Andrei. Why can't you use brk() instead of mmap() if thats what you really want to achieve. 


Thanks,

- Andrei


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux