On Wed, Oct 05, 2016 at 12:34:42PM -0400, Ted Unangst wrote:
> If somebody writes a C program that demonstrates the problem, I'm happy to
> take a look. I'm not installing erlang.

It has been ages since I wrote a C program from scratch, but here goes:

#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>

int main() {
    size_t len = 0;
    void *p1, *p2;

    printf("Pid: %ld\n", (long) getpid());

    /* 12 GB PROT_NONE [anon] */
    p1 = mmap(NULL, ((size_t)12) << 30, PROT_NONE, MAP_ANON, -1, 0);

    /* 200 MB read/write [anon] */
    p2 = mmap(NULL, ((size_t)200) << 20, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);

    printf("p1: %p, p2: %p\n", p1, p2);

    fgetln(stdin, &len);
}


$ ulimit -a
time(cpu-seconds)    unlimited
file(blocks)         unlimited
coredump(blocks)     unlimited
data(kbytes)         16777216
stack(kbytes)        8192
lockedmem(kbytes)    2612782
memory(kbytes)       10000
nofiles(descriptors) 1024
processes            1024
$ ./a.out
Pid: 56334
p1: 0x1bcb47180000, p2: 0x1bca5f100000


# procmap 56334 
:
00001BCA5F100000 204800K read/write          [ anon ]
:
00001BCB47180000 12582912K                     [ anon ]
: 


And the symptom would be that the ulimit -m limit is not immediately
enforced.  The question is if that is a problem?  Or rather if I can use
the ulimit -m limit to prevent a process from taking all memory since I
need to set a large ulimit -d size to do clever address comparision tricks
in the Erlang VM.


/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Reply via email to