FreeBSD's mmap supports MAP_STACK as flags. But when addr is NULL it won't find any suitable addr and try to use addr:0 and fails. Note that manpage has following description and without MAP_STACK it find unallocated space and use it. "If addr is zero, an address will be selected by the system. The actual starting address of the region is returned." How-To-Repeat: Run following program. Both mmap should success but on FreeBSD 8.2 first one fails. #include <sys/mman.h> #include <stdio.h> #include <errno.h> int main (void) { void *ptr; errno = 0; ptr = mmap((void *)0, 1, PROT_READ | PROT_WRITE, MAP_STACK, -1, 0); printf("addr=0: ptr=%p, errno=%d\n", ptr, errno); errno = 0; ptr = mmap((void *)1, 1, PROT_READ | PROT_WRITE, MAP_STACK, -1, 0); printf("addr=1: ptr=%p, errno=%d\n", ptr, errno); return 0; }
For bugs matching the following conditions: - Status == In Progress - Assignee == "bugs@FreeBSD.org" - Last Modified Year <= 2017 Do - Set Status to "Open"