[Gc] "mmap remapping failed" in long-running server

Kenneth C. Schalk ken@xorian.net
Wed, 5 Nov 2003 23:11:47 -0500

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Wed, Nov 05, 2003 at 11:42:42AM -0800, Boehm, Hans wrote:
> Can you

> 1) Apply the attached patch to os_dep.c to print the offending errno, etc.,

> 2) Run the server with the GC_LOOP_ON_ABORT environment variable set, and

> 3) Either check that address in /proc/<server_pid>/maps or send me a copy
> of that file when the server hangs after the failure ?

Given that it's a server that several hundred people depend on, and
that we have it set up with a monitor that restarts it if it
terminates, I'm a little reluctant to use that method.  (It could even
be a little while before I or someone else notices that it's

I'm going to try an alternate patch (attached) which should include
/proc/<server_pid>/maps in the output of the server when it

> I assume you didn't see a message in the system log?

I didn't notice anything, but it was a while ago and I may have missed
it.  We've been running the version without USE_MUNMAP for a while,
and our log rotation seems to have purged those from the last time we
were running the one with USE_MUNMAP.  I'll be sure to double check
after switching USE_MUNMAP back on.

We'll start using the patched server sometime tomorrow, so hopefully
by the end of the week I'll have some more information.


P.S.  Thanks for you prompt reply!

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="os_dep.c.diff2"

--- 6.2/3/src/gc_src/os_dep.c	Thu Oct  9 13:20:46 2003
+++ 6.2/3.remapping_debug/1/src/gc_src/os_dep.c	Wed Nov  5 15:27:34 2003
@@ -115,6 +115,7 @@
 # include <sys/types.h>
 # include <sys/mman.h>
 # include <sys/stat.h>
+# include <errno.h>
 #ifdef UNIX_LIKE
@@ -1814,6 +1815,7 @@
     ptr_t end_addr = GC_unmap_end(start, bytes);
     word len = end_addr - start_addr;
     ptr_t result;
+    char cat_maps_cmd[32];
 #   if defined(MSWIN32) || defined(MSWINCE)
       if (0 == start_addr) return;
@@ -1841,6 +1843,10 @@
       result = mmap(start_addr, len, PROT_READ | PROT_WRITE | OPT_PROT_EXEC,
 		    MAP_FIXED | MAP_PRIVATE, zero_descr, 0);
       if (result != start_addr) {
+	  GC_err_printf3("MMap failed at 0x%lx (length %ld) with errno %ld\n",
+			  start_addr, len, errno);
+	  sprintf(cat_maps_cmd, "cat /proc/%d/maps", getpid());
+	  system(cat_maps_cmd);
 	  ABORT("mmap remapping failed");
       GC_unmapped_bytes -= len;