Changeset: 4cdb1511fbb0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4cdb1511fbb0
Modified Files:
        gdk/gdk_heap.c
        gdk/gdk_private.h
        gdk/gdk_utils.c
        tools/mserver/mserver5.c
Branch: default
Log Message:

Trigger USR1 output when allocation fails during test run.


diffs (141 lines):

diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -155,13 +155,14 @@ HEAPalloc(Heap *h, size_t nitems, size_t
        h->free = 0;
        h->cleanhash = false;
 
-#ifdef SIZE_CHECK_IN_HEAPS_ONLY
        if (GDKvm_cursize() + h->size >= GDK_vm_maxsize &&
            !MT_thread_override_limits()) {
                GDKerror("allocating too much memory (current: %zu, requested: 
%zu, limit: %zu)\n", GDKvm_cursize(), h->size, GDK_vm_maxsize);
+               if (GDKtriggerusr1 &&
+                   !(ATOMIC_GET(&GDKdebug) & TESTINGMASK))
+                       (*GDKtriggerusr1)();
                return GDK_FAIL;
        }
-#endif
 
        size_t allocated;
        if (GDKinmemory(h->farmid) ||
@@ -260,13 +261,14 @@ HEAPextend(Heap *h, size_t size, bool ma
        }
        failure = "size > h->size";
 
-#ifdef SIZE_CHECK_IN_HEAPS_ONLY
        if (GDKvm_cursize() + size - h->size >= GDK_vm_maxsize &&
            !MT_thread_override_limits()) {
                GDKerror("allocating too much memory (current: %zu, requested: 
%zu, limit: %zu)\n", GDKvm_cursize(), size - h->size, GDK_vm_maxsize);
+               if (GDKtriggerusr1 &&
+                   !(ATOMIC_GET(&GDKdebug) & TESTINGMASK))
+                       (*GDKtriggerusr1)();
                return GDK_FAIL;
        }
-#endif
 
        if (h->storage != STORE_MEM) {
                char *p;
@@ -776,13 +778,14 @@ HEAPload(Heap *h, const char *nme, const
                  srcpath, dstpath, ret, ret < 0 ? GDKstrerror(errno, 
(char[128]){0}, 128) : "",
                  GDKusec() - t0);
 
-#ifdef SIZE_CHECK_IN_HEAPS_ONLY
        if (GDKvm_cursize() + h->size >= GDK_vm_maxsize &&
            !MT_thread_override_limits()) {
                GDKerror("allocating too much memory (current: %zu, requested: 
%zu, limit: %zu)\n", GDKvm_cursize(), h->size, GDK_vm_maxsize);
+               if (GDKtriggerusr1 &&
+                   !(ATOMIC_GET(&GDKdebug) & TESTINGMASK))
+                       (*GDKtriggerusr1)();
                return GDK_FAIL;
        }
-#endif
 
        size_t size = h->size;
        QryCtx *qc = NULL;
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -16,9 +16,6 @@
 #error this file should not be included outside its source directory
 #endif
 
-/* only check whether we exceed gdk_vm_maxsize when allocating heaps */
-#define SIZE_CHECK_IN_HEAPS_ONLY 1
-
 #include "gdk_system_private.h"
 
 enum heaptype {
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2414,14 +2414,6 @@ GDKmalloc_internal(size_t size, bool cle
        size_t nsize;
 
        assert(size != 0);
-#ifndef SIZE_CHECK_IN_HEAPS_ONLY
-       if (size > SMALL_MALLOC &&
-           GDKvm_cursize() + size >= GDK_vm_maxsize &&
-           !MT_thread_override_limits()) {
-               GDKerror("allocating too much memory\n");
-               return NULL;
-       }
-#endif
 
        /* pad to multiple of eight bytes and add some extra space to
         * write real size in front; when debugging, also allocate
@@ -2556,15 +2548,6 @@ GDKrealloc(void *s, size_t size)
        nsize = (size + 7) & ~7;
        asize = os[-1];         /* how much allocated last */
 
-#ifndef SIZE_CHECK_IN_HEAPS_ONLY
-       if (size > SMALL_MALLOC &&
-           nsize > asize &&
-           GDKvm_cursize() + nsize - asize >= GDK_vm_maxsize &&
-           !MT_thread_override_limits()) {
-               GDKerror("allocating too much memory\n");
-               return NULL;
-       }
-#endif
 #if !defined(NDEBUG) && !defined(SANITIZER)
        assert((asize & 2) == 0);   /* check against duplicate free */
        /* check for out-of-bounds writes */
@@ -2627,13 +2610,6 @@ GDKmmap(const char *path, int mode, size
 {
        void *ret;
 
-#ifndef SIZE_CHECK_IN_HEAPS_ONLY
-       if (GDKvm_cursize() + len >= GDK_vm_maxsize &&
-           !MT_thread_override_limits()) {
-               GDKerror("requested too much virtual memory; memory requested: 
%zu, memory in use: %zu, virtual memory in use: %zu\n", len, GDKmem_cursize(), 
GDKvm_cursize());
-               return NULL;
-       }
-#endif
        ret = MT_mmap(path, mode, len);
        if (ret != NULL) {
                if (mode & MMAP_COPY)
@@ -2667,14 +2643,6 @@ GDKmremap(const char *path, int mode, vo
 {
        void *ret;
 
-#ifndef SIZE_CHECK_IN_HEAPS_ONLY
-       if (*new_size > old_size &&
-           GDKvm_cursize() + *new_size - old_size >= GDK_vm_maxsize &&
-           !MT_thread_override_limits()) {
-               GDKerror("requested too much virtual memory; memory requested: 
%zu, memory in use: %zu, virtual memory in use: %zu\n", *new_size, 
GDKmem_cursize(), GDKvm_cursize());
-               return NULL;
-       }
-#endif
        ret = MT_mremap(path, mode, old_address, old_size, new_size);
        if (ret != NULL) {
                if (mode & MMAP_COPY) {
diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -239,6 +239,7 @@ static void
 usr1trigger(void)
 {
        usr1_interrupted = 1;
+       MT_sleep_ms(150); /* sleep slightly longer than delay for handling usr1 
*/
 }
 
 #ifdef _MSC_VER
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to