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

Persistent assoc/conj on a transient-created collision node

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Completed
    • Affects versions: Release 1.5
    • Fix versions: Release 1.6
    • Labels:
    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      Bug reported by Zach Tellman https://groups.google.com/d/msg/clojure-dev/HvppNjEH5Qc/1wZ-6qE7nWgJ

      Since transients were introduced the invariant array.length == count*2 doesn't hold for HashCollisionNode.
      However persistent .without still relies on it.

      Hence persistent dissoc on a collision node created by transients fails.

      (let [a (reify Object (hashCode [_] 42))
            b (reify Object (hashCode [_] 42))]
            (= (-> #{a b} transient (disj! a) persistent! (conj a))
             (-> #{a b} transient (disj! a) persistent! (conj a))))
      

      returns false.

      Patch: persistent-assoc-after-collision.diff

      Generative test patch: transient-generative-test.diff

      The generative test reliably reproduces the error. It is simpler than the original test that found the bug but tests a series conj/disj/transient/persistent actions on a set. I've included it separately in case we decide not to apply.

      Screened by: Alex Miller

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cgrand Christophe Grand
            • Votes:
              4 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: