Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma From: toma@tekgvs.LABS.TEK.COM (Tom Almy) Newsgroups: comp.lang.lisp.x Subject: Re: xscheme,xlisp save/restore bug? Keywords: xscheme xlisp bug Message-ID: <6206@tekgvs.LABS.TEK.COM> Date: 21 Oct 89 19:28:59 GMT References: <363@nyit.UUCP> Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy) Organization: Tektronix, Inc., Beaverton, OR. Lines: 41 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