Changeset: a9cfa95160af for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a9cfa95160af
Modified Files:
        gdk/gdk_utils.c
Branch: Jun2016
Log Message:

Enforce setting of gdk_vm_maxsize.
When attempting to memory map a file, check that we don't grow beyond
the limit, and if we do, fail.

Backport of changeset b9ab5b81ef10, and extended for mremap (heap extend).


diffs (30 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1969,8 +1969,13 @@ GDKstrndup(const char *s, size_t n)
 void *
 GDKmmap(const char *path, int mode, size_t len)
 {
-       void *ret = MT_mmap(path, mode, len);
+       void *ret;
 
+       if (GDKvm_cursize() + len >= GDK_vm_maxsize) {
+               GDKerror("allocating too much virtual address space\n");
+               return NULL;
+       }
+       ret = MT_mmap(path, mode, len);
        if (ret == NULL) {
                GDKmemfail("GDKmmap", len);
                ret = MT_mmap(path, mode, len);
@@ -2002,6 +2007,11 @@ GDKmremap(const char *path, int mode, vo
 {
        void *ret;
 
+       if (*new_size > old_size &&
+           GDKvm_cursize() + *new_size - old_size >= GDK_vm_maxsize) {
+               GDKerror("allocating too much virtual address space\n");
+               return NULL;
+       }
        ret = MT_mremap(path, mode, old_address, old_size, new_size);
        if (ret == NULL) {
                GDKmemfail("GDKmremap", *new_size);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to