NetBSD-Bugs archive

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

port-evbarm/49974: mmap(2) of large anonymous regions is broken

>Number:         49974
>Category:       port-evbarm
>Synopsis:       mmap(2) of large anonymous regions is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-evbarm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 15 17:05:01 +0000 2015
>Originator:     Tobias Nygren
>Release:        7.99.18
Banana Pi
mmap(2) of an anonymous 768MB region without address hint at program startup fails. Presumably the system picks a user VA above 1GB (0x6000000) which is not large enough to hold the requested region. If a hint is supplied, then mmap works.

This breaks pkgsrc/lang/openjdk7. It wants to allocate the object heap with mmap and expects that it can get a contiguous region at startup, which is not unreasonable.  The system should figure it needs to use a sub 1GB VA based on the len parameter.
#include <stdio.h>
#include <sys/mman.h>
int main(void) {
        size_t len = 768 * 1024 * 1024;
        void * addr = NULL;
        void *ret;
        /* this call fails */
        ret = mmap(addr, len, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
        if (ret == MAP_FAILED) {
                printf("map without hint failed!\n");
        addr = (void*)0x100000; /* 1MB */
        /* this call works fine */
        ret = mmap(addr, len, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED, -1, 0);
        if (ret == MAP_FAILED) {
                printf("map with hint failed\n");
        printf("%p\n", ret);

unknown. I don't recall having this problem on NetBSD 7, it might be a recent regression.

Home | Main Index | Thread Index | Old Index