[MLton-devel] testMatrix regression segfault

Matthew Fluet fluet@cs.cornell.edu
Tue, 24 Jun 2003 23:11:18 -0400 (EDT)


> The changes over the last 24 hours have introduced a bug that causes a
> segfault in testMatrix.  The bug only happens when compiling -native
> true, so it may be native codegen bug.  In investigating a little, I
> see that the problem is that a limit check is failing and GC_gc is
> being called, even though the frontier should be well below the limit.
> You can verify this by running @MLton fixed-heap 100m --.  With a
> print statement, I can see that the limit is zero.  This makes no
> sense, since this program doesn't use signals or the like.  Any ideas?

Compiling with -debug true and setting a watch on gcState.limit shows that
it is being modified as follows:

Hardware watchpoint 3: gcState.limit

Old value = 0x4001be00 ""
New value = 0x0
L_458 () at testMatrix.0.s:4570


testMatrix.0.s:4570 is:
	fstpL (localReal64+(12*8))

Looking at the addresses:
(gdb) print localReal64
$4 = {0 <repeats 17 times>}
(gdb) print &localReal64
$5 = (int (*)[17]) 0x80678a0
(gdb) print &gcState
$6 = (struct GC_state *) 0x8067900

That doesn't seem right, they are much too close together.
Interestingly, gdb thinks that localReal64 is an int array.

Looking at testMatrix.1.c:

localInt8[0];
localInt16[0];
localInt32[6];
localInt64[0];
localPointer[6];
localReal32[0];
localReal64[17];
localWord8[1];
localWord16[0];
localWord32[5];
Main (4, 8, 0xD, 52, TRUE, TRUE, FALSE, F_0, FALSE)

That should explain it: there are no types on the localX[Z] declarations.
In true C fashion, they are all defaulting to int, so accessing the 12th
element of localReal64 as a real64 array steps way beyond the allocated
area, and stops on gcState.

The bug is in x86-codegen.fun, the declareLocals() function.  It used to
be the case that this function generated a "call" to the Locals macro.
I've checked in the fix that gives a type to each localX[Z] declaration.



-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel