Uploaded image for project: 'Clojure'
  1. CLJ-1511

stack overflow when comparing sequence results

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Completed
    • Affects versions: Release 1.7
    • Fix versions: Release 1.7
    • Labels:
    • Environment:

      OS X 10.9.4

    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      Comparing sequences created with sequence causes a stack overflow when used as first argument to =.

      Consider this transducer:

      user=> (def map-inc (map inc))
      #'user/map-inc
      

      When creating a sequence and comparing with expected results, it works fine as the second argument to the comparison:

      user=> (= (range 1 11) (sequence map-inc (range 10)))
      true
      

      But a stack overflow occurs when the order of arguments is reversed:

      user=> (= (sequence map-inc (range 10)) (range 1 11))
      
      StackOverflowError   clojure.lang.LazyTransformer.equals (LazyTransformer.java:202)
      user=> (clojure.stacktrace/print-stack-trace *e 10)
      java.lang.StackOverflowError: null
       at clojure.lang.LazyTransformer.equiv (LazyTransformer.java:185)
          clojure.lang.LazyTransformer.equals (LazyTransformer.java:202)
          clojure.lang.LazyTransformer.equiv (LazyTransformer.java:185)
          clojure.lang.LazyTransformer.equals (LazyTransformer.java:202)
          clojure.lang.LazyTransformer.equiv (LazyTransformer.java:185)
          clojure.lang.LazyTransformer.equals (LazyTransformer.java:202)
          clojure.lang.LazyTransformer.equiv (LazyTransformer.java:185)
          clojure.lang.LazyTransformer.equals (LazyTransformer.java:202)
          clojure.lang.LazyTransformer.equiv (LazyTransformer.java:185)
          clojure.lang.LazyTransformer.equals (LazyTransformer.java:202)
      nil
      

      The error persists, even if the sequence is forced with doall:

      user=> (= (doall (sequence map-inc (range 10))) (doall (range 1 11)))
      
      StackOverflowError   clojure.lang.LazyTransformer.equiv (LazyTransformer.java:185)
      

      It does work as expected, however, if the sequence is converted to a vector:

      user=> (= (vec (sequence map-inc (range 10))) (range 1 11))
      true
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: