Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by

(def l (range 0 2000)) (run* [q] (appendo l l q))

Stacktrace

`
user=> (def l (range 0 2000))

'user/l

user=> (run* [q] (appendo l l q))
StackOverflowError clojure.core.logic.LVar (logic.clj:1307)
user=> (pst)
StackOverflowError

clojure.core.logic.LVar (logic.clj:1307)
clojure.lang.KeywordLookupSite$1.get (KeywordLookupSite.java:45)
clojure.core.logic.LVar (logic.clj:1325)
clojure.lang.Util.equiv (Util.java:32)
clojure.lang.PersistentHashMap$BitmapIndexedNode.find (PersistentHashMap.java:601)

clojure.lang.PersistentHashMap$ArrayNode.find (PersistentHashMap.java:370)
clojure.lang.PersistentHashMap$ArrayNode.find (PersistentHashMap.java:370)
clojure.lang.PersistentHashMap.entryAt (PersistentHashMap.java:133)
clojure.lang.RT.find (RT.java:720)
clojure.core/find (core.clj:1432)
clojure.core.logic.Substitutions (logic.clj:1134)
clojure.core.logic/walk*/fn--2847 (logic.clj:1005)

`

3 Answers

0 votes
by

Comment made by: dnolen

I cannot recreate on my machine but should try a large N & wait and see.

0 votes
by

Comment made by: norman

It happens for me by 5000. I note the following comment on the implementation of walk-term (the method that blows the stack up) for LCons:

;; TODO: no way to make this non-stack consuming w/o a lot more thinking
;; we could use continuation passing style and trampoline
IWalkTerm
(walk-term (link: v f)

(lcons (f (lfirst v))
       (f (lnext v))))
0 votes
by
Reference: https://clojure.atlassian.net/browse/LOGIC-99 (reported by dnolen)
...