clojure.core.async java.lang.IllegalArgumentException

889 views
Skip to first unread message

Gerrit Jansen van Vuuren

unread,
Jan 7, 2014, 2:25:41 PM1/7/14
to clo...@googlegroups.com
Hi,

I'm getting the following error over and over again in my code, I've tried adding in some print statement and suddenly the error went away and my code worked again, then today I got the same error yet again. I suspect this might be a race condition or something similar. I can take the same library from the repl and it works, but when I use it from inside another app I suddenly get this problem error only at certain times. 

I've removed all close! statements from my code and I still get the same error :(, 

The code is https://github.com/gerritjvv/clj-tcp/blob/master/clj-tcp/src/clj_tcp/client.clj

Exception in thread "async-dispatch-6" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541)
at clojure.core.async.impl.protocols$fn__779$G__774__784.invoke(protocols.clj:21)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:818)
at clj_tcp.client$client$fn__6374.invoke(client.clj:334)
at clojure.lang.AFn.run(AFn.java:24)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

Any ideas?





Luc Prefontaine

unread,
Jan 7, 2014, 3:05:53 PM1/7/14
to clo...@googlegroups.com
You are trying to close a nil
channel.

W/O the code it's all I can say :)
Did you check to make sure
you are not trying to handle nil
as a channel ?

Luc P.
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
Luc Prefontaine<lprefo...@softaddicts.ca> sent by ibisMail!

Gerrit Jansen van Vuuren

unread,
Jan 7, 2014, 3:55:06 PM1/7/14
to clo...@googlegroups.com
I do not have a single close! statement in my code anywhere. I've double checked with grep -lhr "close\!" . through my whole codebase and all the projects in it.

Gerrit Jansen van Vuuren

unread,
Jan 7, 2014, 3:57:57 PM1/7/14
to clo...@googlegroups.com

I've changed all of the go blocks to thread and got an exception that I cannot recur over a try catch. mm.. did not get this error in my go block.
removing the recur's over try catch blocks makes the code work now with both go and thread. At least this is what I've changed now and the error has gone away.

Luc Prefontaine

unread,
Jan 7, 2014, 4:19:39 PM1/7/14
to clo...@googlegroups.com
Maybe hidden in the go macro
expanded code. I do not have access
to it (iPhone).

You may want to use macroexpand
and grep on the expansion.

Just take your go block
and wrap it in

(macroexpand '(your form))

Don't forget the quote.

Maybe the expansion will
shed some light. Do not panic
on the look of the expansion,
the code shuffling is kind of
heavy.

Luc
> > > To post to this group, send email to clo...@googlegroups.com<javascript:>
> > > Note that posts from new members are moderated - please be patient with
> > your first post.
> > > To unsubscribe from this group, send email to
> > > clojure+u...@googlegroups.com <javascript:>
> > > For more options, visit this group at
> > > http://groups.google.com/group/clojure?hl=en
> > > ---
> > > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> > an email to clojure+u...@googlegroups.com <javascript:>.
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> > --
> > Luc Prefontaine<lprefo...@softaddicts.ca <javascript:>> sent by ibisMail!

Luc Prefontaine

unread,
Jan 7, 2014, 4:22:44 PM1/7/14
to clo...@googlegroups.com
Just got your email, I remember
vaguely about this issue maybe when
Tim did is presentation at fhe
Conj.

Or maybe on the mailing list.

You may try what I described
in my previous email and make
your mind about this.

Luc P.

Timothy Baldridge

unread,
Jan 7, 2014, 5:02:07 PM1/7/14
to clo...@googlegroups.com
Like normal clojure code, gos don't support a recur that jumps out through a try. However, the go macro should be patched to bring that to the attention of the user.

Timothy
“One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.”
(Robert Firth)

Gerrit Jansen van Vuuren

unread,
Jan 7, 2014, 5:08:15 PM1/7/14
to clo...@googlegroups.com
Hi,

the pprint of the expansion is:

(let*
 [c__2961__auto__
  (clojure.core.async/chan 1)
  captured-bindings__2962__auto__
  (clojure.lang.Var/getThreadBindingFrame)]
 (clojure.core.async.impl.dispatch/run
  (clojure.core/fn
   []
   (clojure.core/let
    [f__2963__auto__
     (clojure.core/fn
      state-machine__2826__auto__
      ([]
       (clojure.core.async.impl.ioc-macros/aset-all!
        (java.util.concurrent.atomic.AtomicReferenceArray. 13)
        0
        state-machine__2826__auto__
        1
        1))
      ([state_4692]
       (clojure.core/let
        [old-frame__2827__auto__
         (clojure.lang.Var/getThreadBindingFrame)
         ret-value__2828__auto__
         (try
          (clojure.lang.Var/resetThreadBindingFrame
           (clojure.core.async.impl.ioc-macros/aget-object
            state_4692
            3))
          (clojure.core/loop
           []
           (clojure.core/let
            [result__2829__auto__
             (clojure.core/case
              (clojure.core/int
               (clojure.core.async.impl.ioc-macros/aget-object
                state_4692
                1))
              1
              (clojure.core/let
               [inst_4645
                client
                state_4692
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 7
                 inst_4645)]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 2)
                :recur))
              2
              (clojure.core/let
               [inst_4645
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 7)
                inst_4648
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 8)
                inst_4647
                (:write-ch inst_4645)
                inst_4648
                (<!! inst_4647)
                inst_4649
                (instance? Stop inst_4648)
                state_4692
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 8
                 inst_4648)]
               (do
                (if
                 inst_4649
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  4)
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  5))
                :recur))
              3
              (clojure.core/let
               [inst_4690
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                state_4692
                state_4692]
               (clojure.core.async.impl.ioc-macros/return-chan
                state_4692
                inst_4690))
              4
              (clojure.core/let
               [state_4692 state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 6)
                :recur))
              5
              (clojure.core/let
               [inst_4648
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 8)
                inst_4652
                (instance? Reconnected inst_4648)
                state_4692
                state_4692]
               (do
                (if
                 inst_4652
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  7)
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  8))
                :recur))
              6
              (clojure.core/let
               [inst_4688
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                state_4692
                state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 inst_4688
                 1
                 3)
                :recur))
              7
              (clojure.core/let
               [inst_4648
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 8)
                inst_4654
                (:client inst_4648)
                inst_4655
                (error
                 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                 Writer
                 received
                 reconnected
                 inst_4654)
                inst_4656
                (:client inst_4648)
                inst_4645
                inst_4656
                state_4692
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 7
                 inst_4645
                 9
                 inst_4655)]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 2)
                :recur))
              8
              (clojure.core/let
               [inst_4648
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 8)
                inst_4659
                (instance? Pause inst_4648)
                state_4692
                state_4692]
               (do
                (if
                 inst_4659
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  10)
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  11))
                :recur))
              9
              (clojure.core/let
               [inst_4686
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                state_4692
                state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 inst_4686
                 1
                 6)
                :recur))
              10
              (clojure.core/let
               [inst_4648
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 8)
                inst_4661
                (:time inst_4648)
                inst_4662
                (timeout inst_4661)
                state_4692
                state_4692]
               (clojure.core.async.impl.ioc-macros/take!
                state_4692
                13
                inst_4662))
              11
              (clojure.core/let
               [state_4692 state_4692]
               (do
                (if
                 :else
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  14)
                 (clojure.core.async.impl.ioc-macros/aset-all!
                  state_4692
                  1
                  15))
                :recur))
              12
              (clojure.core/let
               [inst_4684
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                state_4692
                state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 inst_4684
                 1
                 9)
                :recur))
              13
              (clojure.core/let
               [inst_4645
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 7)
                inst_4664
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                tmp4693
                inst_4645
                inst_4645
                tmp4693
                state_4692
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 10
                 inst_4664
                 7
                 inst_4645)]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 2)
                :recur))
              14
              (clojure.core/let
               [state_4692 state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 19)
                :recur))
              15
              (clojure.core/let
               [state_4692 state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 16)
                :recur))
              16
              (clojure.core/let
               [inst_4682
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                state_4692
                state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 inst_4682
                 1
                 12)
                :recur))
              17
              (clojure.core/let
               [inst_4645
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 7)
                inst_4678
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                tmp4694
                inst_4645
                inst_4645
                tmp4694
                state_4692
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 7
                 inst_4645
                 11
                 inst_4678)]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 2
                 nil
                 1
                 2)
                :recur))
              18
              (clojure.core/let
               [inst_4668
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 2)
                inst_4669
                (error !!!!! Error while writing inst_4668)
                inst_4670
                (clojure.core/vector inst_4668 1)
                inst_4671
                (>!! internal-error-ch inst_4670)
                inst_4672
                (thread inst_4671)
                state_4692
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 12
                 inst_4669)]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 clojure.core.async.impl.ioc-macros/VALUE-IDX
                 inst_4672)
                (clojure.core.async.impl.ioc-macros/process-exception
                 state_4692)
                :recur))
              19
              (clojure.core/let
               [inst_4645
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 7)
                inst_4648
                (clojure.core.async.impl.ioc-macros/aget-object
                 state_4692
                 8)
                _
                (clojure.core.async.impl.ioc-macros/add-exception-frame
                 state_4692
                 18
                 Exception
                 nil
                 17)
                inst_4676
                (do-write inst_4645 nil inst_4648 false conf)
                state_4692
                state_4692]
               (do
                (clojure.core.async.impl.ioc-macros/aset-all!
                 state_4692
                 clojure.core.async.impl.ioc-macros/VALUE-IDX
                 inst_4676)
                (clojure.core.async.impl.ioc-macros/process-exception
                 state_4692)
                :recur)))]
            (if
             (clojure.core/identical? result__2829__auto__ :recur)
             (recur)
             result__2829__auto__)))
          (catch
           java.lang.Throwable
           ex__2830__auto__
           (clojure.core.async.impl.ioc-macros/aset-all!
            state_4692
            clojure.core.async.impl.ioc-macros/CURRENT-EXCEPTION
            ex__2830__auto__)
           (clojure.core.async.impl.ioc-macros/process-exception
            state_4692)
           :recur)
          (finally
           (clojure.lang.Var/resetThreadBindingFrame
            old-frame__2827__auto__)))]
        (if
         (clojure.core/identical? ret-value__2828__auto__ :recur)
         (recur state_4692)
         ret-value__2828__auto__))))
     state__2964__auto__
     (clojure.core/->
      (f__2963__auto__)
      (clojure.core.async.impl.ioc-macros/aset-all!
       clojure.core.async.impl.ioc-macros/USER-START-IDX
       c__2961__auto__
       clojure.core.async.impl.ioc-macros/BINDINGS-IDX
       captured-bindings__2962__auto__))]
    (clojure.core.async.impl.ioc-macros/run-state-machine-wrapped
     state__2964__auto__))))
 c__2961__auto__)
Reply all
Reply to author
Forward
0 new messages