Runtime bug? and other questions

Daniel Wang danwang@cs.princeton.edu
26 Jan 2000 11:58:18 -0500


"Stephen Weeks" <sweeks@intertrust.com> writes:

> If this doesn't fix your problem, send me the SML code and I'll play
> around with it in my current world.  I can't make a snapshot of the
> whole compiler to give you yet because its so unstable in many other
> places.  Hopefully within a month I'll have a new stable version of
> the whole compiler, and this runtime will tide you over until then.
> 

Hmm looks like the bug is still there.... but only manifests itself when I
*don't* compile with -DGC_EVERY_CHECK

I'm generating the CPS code directly so it doesn't correspond to any SML
program. But roughly it should be the same as

datatype lst = Nil | Cons of int * lst

fun it_rev(Nil,acc) = acc
  | it_rev(Cons(x,xs)) = it_rev(xs,Cons(x,acc))
fun mk_list 0 = [] 
  | mk_list n = (Cons(n,mk_list (n-1)))
val _ = it_rev(mk_list(1000,Nil))

Here's the C code I'm using that's causing the problems.

------------prog.c------
#include "mlton.h"
#define MY_halt() MLTON_halt(0);
#define MY_Int_eq(x,y) ((x) == (y))
#define MY_Int_neq(x,y) ((x) != (y))

Globals(0, 0, 0, 0, 0, 1);
BeginIntInfs
EndIntInfs
BeginStrings
EndStrings
DeclareChunk(125);
DeclareChunk(124);
static void ( *nextChunks[])() = {NULL,NULL,NULL,NULL,Chunkp(124),Chunkp(124),Chunkp(124),Chunkp(124),Chunkp(124),Chunkp(124),Chunkp(124)};
static ushort frameOffsets2[] = {0};
static ushort frameOffsets1[] = {2,4,8};
static ushort frameOffsets0[] = {1,8};
static GC_frameLayout frameLayouts[] = {{0,NULL},{0,NULL},{0,NULL},{0,NULL},{8,frameOffsets2},{4,frameOffsets2},{8,frameOffsets2},{12,frameOffsets0},{12,frameOffsets1},{4,frameOffsets2},{8,frameOffsets2}};
#define initGlobals_62_index 0
#define main5202_0_index 1
#define mk_list5201_0_index 2
#define it_rev5200_0_index 3
#define L_835_index 4
#define L_836_index 5
#define L_837_index 6
#define L_838_index 7
#define L_839_index 8
#define L_840_index 9
#define L_841_index 10
Chunk(125);
ChunkSwitch
case initGlobals_62_index:
	FarJump(124, main5202_0);
EndChunk
Chunk(124);
DI(0);
DI(1);
DI(2);
DP(0);
DP(1);
DP(2);
ChunkSwitch
case main5202_0_index:
	LimitCheck(4, L_840, 0, StackOverflowCheck);
	SI(8) = 1000;
	Push(4);
	SI(0) = L_836_index;
mk_list5201_0:
	LimitCheck(8, L_841, 0, StackOverflowCheck);
	RI(0) = MY_Int_eq(SI(4), 0);
	BZ(RI(0), L_495);
L_496:
	globalpointerNonRoot[0] = IntAsPointer(1);
	Return();
L_495:
	RI(2) = MLTON_Int_sub(SI(4), 1);
	SI(12) = RI(2);
	Push(8);
	SI(0) = L_835_index;
	goto mk_list5201_0;
case mk_list5201_0_index:
	goto mk_list5201_0;
case it_rev5200_0_index:
it_rev5200_0:
	LimitCheck(12, L_839, 12, StackOverflowCheck);
	BZ(IsInt(SP(4)), L_842);
L_494:
	globalpointerNonRoot[0] = SP(8);
	Return();
L_842:
	RP(0) = SP(4);
	RP(1) = OP(RP(0), 4);
	RI(0) = OI(RP(0), 0);
	Object(RP(2), 1, 1);
	AP(4, SP(8));
	AI(0, RI(0));
	EndObject(8);
	SP(8) = RP(2);
	SP(4) = RP(1);
	goto it_rev5200_0;
case L_835_index:
	Push(-8);
	SP(8) = globalpointerNonRoot[0];
	LimitCheck(12, L_838, 12, FALSE);
	RP(0) = SP(8);
	Object(RP(1), 1, 1);
	AP(4, RP(0));
	AI(0, SI(4));
	EndObject(8);
	globalpointerNonRoot[0] = RP(1);
	Return();
case L_836_index:
	Push(-4);
	SP(4) = globalpointerNonRoot[0];
	RP(0) = SP(4);
	SP(16) = IntAsPointer(1);
	SP(12) = RP(0);
	Push(8);
	SI(0) = L_837_index;
	goto it_rev5200_0;
case L_837_index:
	Push(-8);
	SP(8) = globalpointerNonRoot[0];
	RP(1) = SP(8);
	MY_halt();
		Return();
case L_838_index: goto L_838;
case L_839_index: goto L_839;
case L_840_index: goto L_840;
case L_841_index: goto L_841;
EndChunk
Main(FALSE, 0, 0, 12, 11, 0xd, 125, initGlobals_62)