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

Piping seque into seque can deadlock

    Details

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

      Windows 7; JVM 1.6; Clojure 1.3 beta 1

    • Approval:
      Ok
    • Patch:
      Code and Test

      Description

      I'm not sure if this is a supported scenario, but the following deadlocks in Clojure 1.3:

      (let [xs (seque (range 150000))
            ys (seque (filter odd? xs))]
        (apply + ys))
      

      Cause: As I understand it, the problem is that ys' fill takes place on an agent thread, so when it calls xs' drain, the (send-off agt fill) does not immediately trigger xs' fill, but is instead put on the nested list to be performed when ys' agent returns. Unfortunately, ys' fill will eventually block trying to take from xs, and so it never returns and the pending send-offs are never sent.

      Approach: Use (release-pending-sends) in seque's drain function to avoid the deadlock when a seque is fed into another seque.

      Patch: clj-823-v1.patch

      Screened by: Alex Miller

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              glchapman Greg Chapman
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: