]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: handle locked mmap failure on Linux
authorSébastien Paolacci <sebastien.paolacci@gmail.com>
Sat, 29 Dec 2012 19:34:06 +0000 (14:34 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 29 Dec 2012 19:34:06 +0000 (14:34 -0500)
Used to then die on a nil pointer situation. Most Linux standard setups are rather
restrictive regarding the default amount of lockable memory.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6997049

src/pkg/runtime/mem_linux.c

index b3e79cc412c9691042100f5bb34e1bcabe02f864..db1975f4ca838ff3d3fc85c0ba99f060712e51fa 100644 (file)
@@ -10,6 +10,7 @@
 
 enum
 {
+       EAGAIN = 11,
        ENOMEM = 12,
        _PAGE_SIZE = 4096,
 };
@@ -63,6 +64,10 @@ runtime·SysAlloc(uintptr n)
                        runtime·printf("if you're running SELinux, enable execmem for this process.\n");
                        runtime·exit(2);
                }
+               if(p == (void*)EAGAIN) {
+                       runtime·printf("runtime: mmap: too much locked memory (check 'ulimit -l').\n");
+                       runtime·exit(2);
+               }
                return nil;
        }
        return p;