core.async

Writing on a closed channel doesn't commit the handler

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

(let [closed (doto (a/chan) a/close!)
      open (a/chan)]
  (a/go-loop []
    (a/alts! [open [closed true]] :priority true)
    (recur)))

throws

Exception in thread "async-dispatch-1" java.lang.AssertionError: Assert failed: No more than 1024 pending takes are allowed on a single channel.
(< (.size takes) impl/MAX-QUEUE-SIZE)
	at clojure.core.async.impl.channels.ManyToManyChannel.take_BANG_(channels.clj:235)
	at clojure.core.async$do_alts$fn__8030.invoke(async.clj:253)
	at clojure.core.async$do_alts.invokeStatic(async.clj:245)
	at clojure.core.async$do_alts.invoke(async.clj:237)

my analysis is that when a write is attempted on a closed channel the handler should be commited, so as to allow cleanup of the handler registrations on other channels.

See https://github.com/clojure/core.async/blob/822920a45e5ea7fa28641922559fdeb888c15d05/src/main/clojure/clojure/core/async/impl/channels.clj#L74-L75

Activity

Hide
Christophe Grand added a comment -

Attached patch

Show
Christophe Grand added a comment - Attached patch
Hide
Danny Guinther added a comment -

Thanks for documenting and offering a patch for this defect, Christophe!

Is there something blocking further action on this defect/patch? Is there anything I can do to help move a fix forward?

I can confirm the existence of this defect and that the attached patch remedies the problem. I can also confirm that all tests pass with the attached patch applied to the latest revision of core.async (https://github.com/clojure/core.async/commit/196f87dc21f55f601c867b796a0a421550b43c8f).

In the system I encountered this bug on, the actual root problem was that the channel being put to was being closed prematurely. In fact, if this bug didn't exist, my team probably wouldn't have noticed the put channel being closed prematurely (in fact, we didn't notice for months until the right circumstances arose). Perhaps obscuring such problems is part of the reason the suggested patch hasn't been accepted?

Any suggestions for actionable next steps are appreciated.

Show
Danny Guinther added a comment - Thanks for documenting and offering a patch for this defect, Christophe! Is there something blocking further action on this defect/patch? Is there anything I can do to help move a fix forward? I can confirm the existence of this defect and that the attached patch remedies the problem. I can also confirm that all tests pass with the attached patch applied to the latest revision of core.async (https://github.com/clojure/core.async/commit/196f87dc21f55f601c867b796a0a421550b43c8f). In the system I encountered this bug on, the actual root problem was that the channel being put to was being closed prematurely. In fact, if this bug didn't exist, my team probably wouldn't have noticed the put channel being closed prematurely (in fact, we didn't notice for months until the right circumstances arose). Perhaps obscuring such problems is part of the reason the suggested patch hasn't been accepted? Any suggestions for actionable next steps are appreciated.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: