I've run this a bunch of times (in BOTH `lein repl` and `java -cp [...] 
clojure.main`), and have observed both this code printing the OOM 
exception, and it being silent as you observed. 

The difference in trials *seems* to be that if I skip the intermediate 
steps, going straight for the big one - (<!! (thread-add 10 2000)) - then I 
get the exception printed: Exception in thread "async-thread-macro-1999" 
java.lang.OutOfMemoryError: unable to create new native thread. Whereas if 
I do this first - (<!! (thread-add 10 1000)) - then I get the silent error 
as you are seeing. This seems pretty repeatable, but I don't really 
understand.

It looks like Exceptions (Throwables, really) will never propagate from the 
executor that `thread-call` calls, since they're swallowed in core.async: 
https://github.com/clojure/core.async/blob/ae37883a10dc9249ac5f204f6900e7bb0dbe1e04/src/main/clojure/clojure/core/async.clj#L381-L382

Maybe whether the error prints or not depends on whether the exception gets 
raised on the receiving side (the main thread) or the sending side 
(presumably on an Executor)?




On Sunday, December 8, 2013 9:27:44 AM UTC-6, Paul Butcher wrote:
>
> On 8 Dec 2013, at 14:21, Alex Miller <al...@puredanger.com <javascript:>> 
> wrote:
>
> If you're starting with lein repl then I would expect errors to be printed 
> at the console - that's the actual process running the code. It's also 
> possible that the thread's untaught exception handler doesn't print. I know 
> that the expectation for async go blocks is that you should catch and 
> handle any error. Have tried catching Throwable in your thread block and 
> printing?
>
>
> Yup - that works fine (see below).
>
> The implication, I guess, is that nrepl doesn't set the default uncaught 
> exception handler? I find that surprising?
>
> user=> (require '[clojure.core.async :refer [thread <!!]])
> nil
> user=> (defn thread-add [x y]
>   #_=>   (thread
>   #_=>     (try
>   #_=>       (if (zero? y)
>   #_=>         x
>   #_=>         (let [t (thread-add (inc x) (dec y))]
>   #_=>           (<!! t)))
>   #_=>       (catch Throwable e (println e)))))
> #'user/thread-add
> user=> (<!! (thread-add 10 10))
> 20
> user=> (<!! (thread-add 10 2000))
> Exception in thread "async-thread-macro-1986" java.lang.OutOfMemoryError: 
> unable to create new native thread
> at java.lang.Thread.start0(Native Method)
> at java.lang.Thread.start(Thread.java:691)
> at 
> java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
> at 
> java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:992)
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
>
>
> --
> paul.butcher->msgCount++
>
> Silverstone, Brands Hatch, Donington Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> Skype: paulrabutcher
>
>
>
>  
> On 8 Dec 2013, at 14:21, Alex Miller <al...@puredanger.com <javascript:>> 
> wrote:
>
> If you're starting with lein repl then I would expect errors to be printed 
> at the console - that's the actual process running the code. It's also 
> possible that the thread's untaught exception handler doesn't print. I know 
> that the expectation for async go blocks is that you should catch and 
> handle any error. Have tried catching Throwable in your thread block and 
> printing?
>
> -- 
> -- 
> 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 <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.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to