core.logic

StackOverflow for large `appendo`

Details

  • Type: Defect Defect
  • Status: In Progress In Progress
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

(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)

Activity

Hide
David Nolen added a comment -

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

Show
David Nolen added a comment - I cannot recreate on my machine but should try a large N & wait and see.
Hide
Norman Richards added a comment -

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 [v f]
(lcons (f (lfirst v))
(f (lnext v))))

Show
Norman Richards added a comment - 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 [v f] (lcons (f (lfirst v)) (f (lnext v))))

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: