From Alain.Picard at memetrics.com Wed Aug 31 04:11:01 2005 From: Alain.Picard at memetrics.com (Alain.Picard at memetrics.com) Date: Wed, 31 Aug 2005 14:11:01 +1000 Subject: [Cl-store-devel] bug restoring long lists Message-ID: Dear Maintainers, Under Lispworks and SBCL, trying to store and restore a long list fails. (SBCL can handle a much, much longer list than LW, but still fails). Here's what happens: XOS> (setq l (loop for i below 10000 collect i) foo 'ok) OK XOS> (progn (store l "/tmp/list.1") 'ok) OK XOS> (progn (restore "/tmp/list.1") 'ok) ; Evaluation aborted Raises: Stack overflow (stack size 16000). [Condition of type CONDITIONS:STACK-OVERFLOW] Restarts: 0: [ABORT] Abort handling SLIME request. 1: [ABORT] Quit process. Backtrace: XOS> (let ((*check-for-circs* nil)) (progn (restore "/tmp/list.1") 'ok)) ; Evaluation aborted Raises same error. The problem is non tail recursive manner in which it restores lists as a nested series of conses. I have a private patch, which just stores "proper lists" differently, but I thought you'd want to know and perhaps implement something better than my hack. I notice you know have this *CHECK-FOR-CIRCS* variable (I was still using an old version) --- perhaps when within a context of *CHECK-FOR-CIRCS* of NIL you can dispatch to an entirely different (and stack-safe) algorithm? Just a thought. --Alain Picard p.s. please CC me; I'm not on this list (though maybe I should be...) -- It would be difficult to construe Larry Wall, in article this as a feature. <1995May29.062427.3640 at netlabs.com> From sdr at jhb.ucs.co.za Wed Aug 31 15:12:08 2005 From: sdr at jhb.ucs.co.za (Sean Ross) Date: 31 Aug 2005 17:12:08 +0200 Subject: [Cl-store-devel] bug restoring long lists References: Message-ID: <87oe7e3zuf.fsf@sdr.ucs.co.za> Alain.Picard at memetrics.com writes: Hi Alain, thanks for the report, I've also run into this problem a couple of times but wasn't quite too sure what the right approach would be. > > I have a private patch, which just stores "proper lists" differently, > but I thought you'd want to know and perhaps implement something > better than my hack. I'm not so sure :-) Right now i'm trying a slightly long winded approach by using list-length to figure out what kind of list is passed in (proper, dotted or circular) which looks something like this. (defun proper-list-length (list) "Returns 2 values the first being the lenght of the list if it is a proper-list or NIL of it is a circular list. The second value can be checked to see if LIST is a dotted list." (ignore-errors (list-length list))) (multiple-value-bind (length errorp) (proper-list-length list) (cond (errorp (dump-atomed-list list stream)) (length (dump-proper-list list length stream)) (t (dump-circular-list list stream)))) Each dumper function then takes a more respectable approach to serializing the list. Any comments? What approach were you taking? Regards, Sean. -- "My doctor says that I have a malformed public-duty gland and a natural deficiency in moral fibre," he muttered to himself, "and that I am therefore excused from saving Universes." - Life, the Universe, and Everything Douglas Adams. Confidentiality Notice: http://ucs.co.za/conf.html From Alain.Picard at memetrics.com Wed Aug 31 22:36:17 2005 From: Alain.Picard at memetrics.com (Alain.Picard at memetrics.com) Date: Thu, 1 Sep 2005 08:36:17 +1000 Subject: [Cl-store-devel] bug restoring long lists In-Reply-To: <87oe7e3zuf.fsf@sdr.ucs.co.za> References: <87oe7e3zuf.fsf@sdr.ucs.co.za> Message-ID: <17174.12513.182468.685653@memetrics.com> Sean Ross writes: > Right now i'm trying a slightly long winded approach by using list-length > to figure out what kind of list is passed in (proper, dotted or circular) > which looks something like this. [SNIP] That's eerie. That's almost _exactly_ what I did. :-) > Any comments? Well, it's the best I could come up with, so I'm obviously starting to understand your code. I can send it to you if you wish. Lastly, I'd comment that.... I find cl-store quite useful. We use CommonSQL, but it turns out that for a lot of odds and ends, it's often just easier to store a "regular" lisp object in a slot with cl-store than to worry about schemas, etc. Cheers, --ap