2009-09-16 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Wed, 16 Sep 2009 08:55:33 +0000 (08:55 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:46 +0000 (21:06 +0400)
(ivmai125.diff)

* os_dep.c (GC_wince_get_mem): If VirtualAlloc() returns NULL (due
to out of memory) then don't increment GC_n_heap_bases and don't
call VirtualAlloc() again (with MEM_COMMIT).
* os_dep.c (GC_remap): Abort with a more informatory message if
VirtualAlloc() fails due to out of memory; update FIXME.

ChangeLog
os_dep.c

index 23e0c1e..eb375f7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,13 @@
 2009-09-16  Ivan Maidanski <ivmai@mail.ru>
+       (ivmai125.diff)
+
+       * os_dep.c (GC_wince_get_mem): If VirtualAlloc() returns NULL (due
+       to out of memory) then don't increment GC_n_heap_bases and don't
+       call VirtualAlloc() again (with MEM_COMMIT).
+       * os_dep.c (GC_remap): Abort with a more informatory message if
+       VirtualAlloc() fails due to out of memory; update FIXME.
+
+2009-09-16  Ivan Maidanski <ivmai@mail.ru>
        (ivmai132.diff - superseding diff41a, diff64, diff84 partly)
 
        * Makefile: Fix typo for msvc_dbg.c.
index 6aaaa10..63436a8 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1962,6 +1962,7 @@ ptr_t GC_wince_get_mem(word bytes)
            /* If I read the documentation correctly, this can  */
            /* only happen if HBLKSIZE > 64k or not a power of 2.       */
        if (GC_n_heap_bases >= MAX_HEAP_SECTS) ABORT("Too many heap sections");
+       if (result == NULL) return NULL;
        GC_heap_bases[GC_n_heap_bases] = result;
        GC_heap_lengths[GC_n_heap_bases] = 0;
        GC_n_heap_bases++;
@@ -2066,7 +2067,7 @@ void GC_remap(ptr_t start, size_t bytes)
     ptr_t end_addr = GC_unmap_end(start, bytes);
     word len = end_addr - start_addr;
 
-    /* FIXME: Should we handle out-of-memory here? */
+    /* FIXME: Handle out-of-memory correctly (at least for Win32)      */
 #   if defined(MSWIN32) || defined(MSWINCE)
       ptr_t result;
 
@@ -2082,7 +2083,12 @@ void GC_remap(ptr_t start, size_t bytes)
                                MEM_COMMIT,
                                PAGE_EXECUTE_READWRITE);
          if (result != start_addr) {
-             ABORT("VirtualAlloc remapping failed");
+             if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
+                 GetLastError() == ERROR_OUTOFMEMORY) {
+                 ABORT("Not enough memory to process remapping");
+             } else {
+                 ABORT("VirtualAlloc remapping failed");
+             }
          }
          GC_unmapped_bytes -= alloc_len;
          start_addr += alloc_len;