Clojure

*agent* is nil in action fns, regression in Clojure 1.3a3

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure 1.3a3
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Should return true, and does so in Clojure 1.2:

(let [a (agent 1)]
  (send a (fn [_] (= a *agent*)))
  (await a)
  @a)

In recent Clojure 1.3 alphas, the above returns false because *agent* is nil.

This appears to be because the fn created by binding-conveyor-fn resets the binding frame after *agent* is bound, effectively binding it back to nil. This is the cause of the heisenbug recently reported for CLJ-390.

Activity

Hide
Chouser added a comment - - edited

Add support for an optional binding-map to binding-conveyor-fn to be applied after resetThreadBindingFrame. Use this in send and send-off to bind *agent* as appropriate. Remove the now unnecessary *agent* binding code from Agent.doRun()

Add test that previously failed and now passes.

Show
Chouser added a comment - - edited Add support for an optional binding-map to binding-conveyor-fn to be applied after resetThreadBindingFrame. Use this in send and send-off to bind *agent* as appropriate. Remove the now unnecessary *agent* binding code from Agent.doRun() Add test that previously failed and now passes.
Hide
Chouser added a comment -

Please ignore the previous, embarrassingly complex patch. 0002-* should be used instead of the earlier patch. This one accomplishes the same results without changing binding-conveyor-fn at all.

Show
Chouser added a comment - Please ignore the previous, embarrassingly complex patch. 0002-* should be used instead of the earlier patch. This one accomplishes the same results without changing binding-conveyor-fn at all.
Hide
Rich Hickey added a comment - - edited

I don't think this is quite right. The binding of *agent* should just wrap the call to binding-conveyor-fn, not the call to dispatch.

Show
Rich Hickey added a comment - - edited I don't think this is quite right. The binding of *agent* should just wrap the call to binding-conveyor-fn, not the call to dispatch.
Hide
Stuart Halloway added a comment -

This defect was also causing the "Pop without matching push" whenever an agent send came from a newly-minted thread. (The conveyance was happening inside a push/pop pair in Agent.doRun.

Second patch addresses Rich's comment, and adds a test for the "pop without push" problem.

Show
Stuart Halloway added a comment - This defect was also causing the "Pop without matching push" whenever an agent send came from a newly-minted thread. (The conveyance was happening inside a push/pop pair in Agent.doRun. Second patch addresses Rich's comment, and adds a test for the "pop without push" problem.
Hide
Stuart Halloway added a comment -

And be second patch, I mean third patch. The one dated 29 Nov.

Show
Stuart Halloway added a comment - And be second patch, I mean third patch. The one dated 29 Nov.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: