[MLton-commit] r6596

Matthew Fluet fluet at mlton.org
Sun Apr 20 15:04:20 PDT 2008


Fixed bug in code to page the heap to disk when unable to grow the heap to a desired size.

----------------------------------------------------------------------

U   mlton/trunk/doc/changelog
U   mlton/trunk/runtime/platform/diskBack.unix.c
U   mlton/trunk/runtime/util/safe.h

----------------------------------------------------------------------

Modified: mlton/trunk/doc/changelog
===================================================================
--- mlton/trunk/doc/changelog	2008-04-20 15:02:27 UTC (rev 6595)
+++ mlton/trunk/doc/changelog	2008-04-20 22:04:19 UTC (rev 6596)
@@ -1,5 +1,10 @@
 Here are the changes from version 20070826 to version YYYYMMDD.
 
+* 2008-04-20
+   - Fixed bug in code to page the heap to disk when unable to grow
+     the heap to a desired size.
+     Thanks to Nicolas Bertolotti for the bug report.
+
 * 2008-04-07
    - More flexible active/paused stack resizing policy.
      Removed thread-shrink-ratio runtime option.

Modified: mlton/trunk/runtime/platform/diskBack.unix.c
===================================================================
--- mlton/trunk/runtime/platform/diskBack.unix.c	2008-04-20 15:02:27 UTC (rev 6595)
+++ mlton/trunk/runtime/platform/diskBack.unix.c	2008-04-20 22:04:19 UTC (rev 6596)
@@ -35,6 +35,7 @@
   FILE *f;
 
   f = ((WriteToDiskData)data)->f;
+  fseek_safe (f, 0, SEEK_SET);
   fread_safe (buf, 1, size, f);
 }
 

Modified: mlton/trunk/runtime/util/safe.h
===================================================================
--- mlton/trunk/runtime/util/safe.h	2008-04-20 15:02:27 UTC (rev 6595)
+++ mlton/trunk/runtime/util/safe.h	2008-04-20 22:04:19 UTC (rev 6596)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
+/* Copyright (C) 1999-2008 Henry Cejtin, Matthew Fluet, Suresh
  *    Jagannathan, and Stephen Weeks.
  * Copyright (C) 1997-2000 NEC Research Institute.
  *
@@ -58,6 +58,16 @@
   }
 }
 
+static inline int fseek_safe (FILE *f, long offset, int whence) {
+  int res;
+
+  res = fseek (f, offset, whence);
+  if (-1 == res)
+    diee ("fseek (_, %"PRIuMAX", %"PRIuMAX") failed.\n",
+          (uintmax_t)offset, (uintmax_t)whence);
+  return res;
+}
+
 static inline void fwrite_safe (const void *buf, size_t size, size_t count,
                                 FILE *f) {
   size_t res;




More information about the MLton-commit mailing list