Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Oct 2020 16:53:11 +0300
From:      Nick Kostirya <nikolay.kostirya@i11.co>
To:        freebsd-stable@freebsd.org
Subject:   mmap and MAP_STACK
Message-ID:  <20201021165311.186bd606@i11.co>

next in thread | raw e-mail | index | archive | help
Hello.
I have question about mmap.

void *OSMem::AllocateDataArea(size_t &space)
{
    // Round up to an integral number of pages.
    space = (space + pageSize-1) & ~(pageSize-1);
    int fd = -1; // This value is required by FreeBSD.  Linux doesn't care
    int flags = MAP_PRIVATE | MAP_ANON;
#ifdef MAP_STACK
    if (memUsage == UsageStack) flags |= MAP_STACK; // OpenBSD seems to require this
#endif
    void *result = mmap(0, space, PROT_READ|PROT_WRITE, flags, fd, 0);
    // Convert MAP_FAILED (-1) into NULL
    if (result == MAP_FAILED)
        return 0;
    return result;
}


When MAP_STACK is used, "insufficient memory" error occurs.
When MAP_STACK removed, it is all right.

Please tell me why.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201021165311.186bd606>