[MLton-devel] bug fix for MLton 20030312 runtime
Stephen Weeks
MLton@mlton.org
Fri, 9 May 2003 12:29:30 -0700
Hi Alain. I just found and fixed a bug in the MLton runtime that
could cause a segfault. The bug was introduced on Aug 7, 2002, and
was in both the 20020923 and 20030312 releases. The bug would happen
if the heap was allocated at a very low (<10M) address, which actually
happened on a user's Cygwin system.
Here is patch to gc.c that fixes the bug. I recommend applying the
patch before shipping anything compiled with 20030312. Let us know if
there is a problem.
--------------------------------------------------------------------------------
diff -u -r1.130 -r1.131
--- gc.c 2 May 2003 23:47:49 -0000 1.130
+++ gc.c 9 May 2003 18:21:45 -0000 1.131
@@ -2635,19 +2635,25 @@
/* Allocate a space of the desired size. */
if (heapCreate (s, &h2, desired, minSize)) {
pointer from;
+ uint remaining;
pointer to;
from = old + size;
to = h2.start + size;
+ remaining = size;
copy:
- from -= COPY_CHUNK_SIZE;
- to -= COPY_CHUNK_SIZE;
- if (from > old) {
+ assert (remaining == from - old
+ and from >= old and to >= h2.start);
+ if (remaining < COPY_CHUNK_SIZE) {
+ copy (old, h2.start, remaining);
+ } else {
+ remaining -= COPY_CHUNK_SIZE;
+ from -= COPY_CHUNK_SIZE;
+ to -= COPY_CHUNK_SIZE;
copy (from, to, COPY_CHUNK_SIZE);
- heapShrink (s, h, from - old);
+ heapShrink (s, h, remaining);
goto copy;
}
- copy (old, h2.start, from + COPY_CHUNK_SIZE - old);
heapRelease (s, h);
*h = h2;
} else {
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel