puniverse / pulsar

Fibers, Channels and Actors for Clojure
http://docs.paralleluniverse.co/pulsar/
Other
911 stars 53 forks source link

println in fiber: java.lang.IllegalArgumentException: wrong number of arguments #32

Closed dehubbed closed 9 years ago

dehubbed commented 9 years ago

Just starting out with pulsar (0.6.2), maybe I'm doing something wrong, but

(ns borked
  (:require [co.paralleluniverse.pulsar.core :as p]))

(p/spawn-fiber (fn [] (println "test")))

results in

Exception in Fiber "fiber-10000002" java.lang.IllegalArgumentException: wrong number of arguments
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
    at clojure.tools.nrepl.middleware.session$session_out$fn__1390.doInvoke(session.clj:41)
    at clojure.lang.RestFn.invoke(RestFn.java:460)
    at clojure.tools.nrepl.middleware.session.proxy$java.io.Writer$ff19274a.write(Unknown Source)
    at java.io.PrintWriter.write(PrintWriter.java:456)
    at java.io.PrintWriter.write(PrintWriter.java:473)
    at clojure.core$fn__5471.invoke(core_print.clj:191)
    at clojure.lang.MultiFn.invoke(MultiFn.java:231)
    at clojure.core$pr_on.invoke(core.clj:3392)
    at clojure.core$pr.invoke(core.clj:3404)
    at clojure.lang.AFn.applyToHelper(AFn.java:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$prn.doInvoke(core.clj:3437)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:624)
    at clojure.core$println.doInvoke(core.clj:3457)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at borked$eval2177$fn__2178.invoke(NO_SOURCE_FILE:1)
    at co.paralleluniverse.pulsar.InstrumentedIFn.invoke(InstrumentedIFn.java:32)
    at co.paralleluniverse.pulsar.ClojureHelper.suspendableInvoke(ClojureHelper.java:185)
    at co.paralleluniverse.pulsar.ClojureHelper$3.run(ClojureHelper.java:172)
    at co.paralleluniverse.fibers.Fiber.run(Fiber.java:1003)
dehubbed commented 9 years ago

The above only happens in nrepl (via Eclipse). Seems nrepl is somehow getting in the way. Strange. Someone had a similar problem: https://groups.google.com/forum/#!topic/quasar-pulsar-user/TkgWpuIiI80

However can't just blame it on nrepl, it all works with "future-call" instead of spawn-fiber.

circlespainter commented 9 years ago

Yes, I just tried with a lein run (with a main method) and lein repl and they work ok. Not an expert of nrepl w/ Eclipse, is the Quasar agent running ok? If everything seems regular, could you please try 0.6.3-SNAPSHOT as well?

dehubbed commented 9 years ago

sure give me 1 hr

dehubbed commented 9 years ago

0.6.3-SNAPSHOT is not on clojars, is it? should I clone the repo and build it?

dehubbed commented 9 years ago

ok I cloned & compiled, same issue. I or anyone can make do without the Eclipse nrepl for sure, however it is a bit worrying that there should be subtle interactions like that.

dehubbed commented 9 years ago

using clojure.tools.logging (via slf4j and log4j) and doing (debug "test") instead of (println "test") works. even though debug uses println somewhere down in its guts. ah well.

circlespainter commented 9 years ago

I just installed Eclipse Luna for Java + CCW and I'm trying hard to reproduce it but I'm not able to, maybe I'm doing something wrong.

I'm on JDK 1.8.0_25, Mac OS X Yosemite, I tried creating a Leiningen project with Quasar/Pulsar setup, then I right-clicked it and "Leiningen/Launch Headless REPL for the project", finally in the REPL I pasted your snippet but I get "nil" as a return value and "test" in stdout without any exceptions.

Should I do something else?

dehubbed commented 9 years ago

I'm on Ubuntu JDK 1.7. I don't have a Mac here but I can try JDK 1.8 later today.

dehubbed commented 9 years ago

Just tried JDK 8, same thing. No idea how to reproduce this any other way. I think you can close this issue. I could reopen it should I come across further clues.

circlespainter commented 9 years ago

Are the steps I'm following to reproduce it right? Are you doing the same things?

dehubbed commented 9 years ago

Yes, the step are right and you are doing the same thing, other than my OS being Ubuntu which should hardly matter. Counterclockwise version is 0.31.1?

Can I send you a tgz file somehow with my bare bones Eclipse project in it that you can run unzip and run?

dehubbed commented 9 years ago

File here: https://mega.co.nz/#!us8gFLBB!1CQ7JOp8F1HEoyOVJI2dM4AsRMMSgRSjPtT9-zAfrU4

dehubbed commented 9 years ago

There is an Eclipse launch configuration in that package, that's what I use to launch it.

circlespainter commented 9 years ago

Thanks, I'll have a look ASAP.

circlespainter commented 9 years ago

Yes, CCW is 0.31.1.STABLE001. Tried with your project and launch config (I adjusted just the path to Quasar's agent to use my home), connected to it with lein repl :connect, copied and pasted your borked.clj test content and still I get no exception. Have you got a chance to try on some other machine / setup?

dehubbed commented 9 years ago

Will do.

dehubbed commented 9 years ago

Yes I tried a different machine and everything works completely fine. Up to me now to figure out what the crucial difference is! =8-O I'll keep you posted.

dehubbed commented 9 years ago

btw related to this? https://github.com/puniverse/pulsar/issues/29

circlespainter commented 9 years ago

I won't rule it out completely but I think it's unlikely as that issue was reproducible everywhere, every time and you're trying (or have tried already) with pulsar 0.6.3 which contains a fix for it.

circlespainter commented 9 years ago

I'll close it for now, if more info will be available about reproducing it we can always reopen it.