[comp.lang.lisp.x] xscheme,xlisp save/restore bug?

zilla@nyit.UUCP (John Lewis) (10/20/89)

There is a major bug in the xscheme (0.17) save/restore functions.
Since this code was adapted directly from Xlisp2.0, i'm wondering
whether there is a similar problem in Xlisp (& a fix, hopefully),
or why it isn't a problem.

i'm not sure i can characterize the bug very well (if i could i 
would be on the way to fixing it), but my guess is that it involves
the interaction of garbage collection with restore- the image is
restored in node-array order, so collectable nodes may be restored
before the symbols they are attached to; garbage collection can
be triggered by creation of nodes during the restore, and this
GC can incorrectly free some of the partially restored image.

In any case, (restore) does not work (see recent mail on comp.lang.scheme).

Thanks for any advice
jp lewis@nyit computer graphics lab
516 686 7644(evenings)

toma@tekgvs.LABS.TEK.COM (Tom Almy) (10/22/89)

In article <363@nyit.UUCP> zilla@nyit.UUCP (John Lewis) writes:
>There is a major bug in the xscheme (0.17) save/restore functions.
>Since this code was adapted directly from Xlisp2.0, i'm wondering
>whether there is a similar problem in Xlisp (& a fix, hopefully),
>or why it isn't a problem.

I thought the same, but it turns out the problems are different, although
related to garbage collection.
Here are the restore function fixes for xlisp 2.0:


*******************
Problem: "restore" corrupts system.
Diagnosis: argument stack not being reset -- initial garbage collect
 "marks" random memory!

Solution: Add to "initialize" in xlirestore:


	xlfp = xlsp = xlargstkbase;
	*xlsp++ = NIL;

Problem: "restore" corrupts system with 8086 compilers.
Diagnosis: cvoptr is doing improper arithmetic.

Solution: CVPTR in xlisp.h needs to be defined as 
#define CVPTR(x)	((((unsigned long)(x) >> 16) << 4) + ((unsigned) x))
	return statement in cvoptr() (xlimage.c) needs to be changed from:
return (off + (OFFTYPE)((p - seg->sg_nodes) << 1));
	to:
return (off+(((CVPTR(p)-CVPTR(seg->sg_nodes))/sizeof(struct node))<<1));


Note: for this to work with non-8086 compilers, the default in xlisp.h for 
CVPTR should be changed from (x) to ((OFFTYPE)(x)).



Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply