Thread overview
Re: Assert failures in threads
Jul 09, 2013
Sean Kelly
Jul 09, 2013
Jonathan M Davis
Jul 10, 2013
Sean Kelly
July 09, 2013
On Jul 1, 2013, at 4:04 AM, Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> wrote:

> I've noticed that when an assert fails inside a thread, no error message is printed and the program/thread just hangs.
> 
> Is there any way to ensure that an assertion failure inside a thread does output a message?  For the purposes of my current needs, it's fine if it also brings down the whole program, just so long as I'm alerted to what generated the error.

If you join the thread, any unhanded exception will be rethrown in the joining thread by default.  Or you can have a catch(Throwable) in the top level of your thread function.  I thought about adding an overridable unhandled exception filter (I think Java has something like this) but that seemed like it would interact strangely with the join behavior.
July 09, 2013
On Tuesday, July 09, 2013 10:39:59 Sean Kelly wrote:
> If you join the thread, any unhanded exception will be rethrown in the joining thread by default.

What about threads which were spawned by std.concurrency? IIRC, those are never explicitly joined. Is catching Throwable in the spawned thread required in order to get stuff like AssertErrors printed?

- Jonathan M Davis
July 10, 2013
On Jul 9, 2013, at 3:33 PM, Jonathan M Davis <jmdavisProg@gmx.com> wrote:

> On Tuesday, July 09, 2013 10:39:59 Sean Kelly wrote:
>> If you join the thread, any unhanded exception will be rethrown in the joining thread by default.
> 
> What about threads which were spawned by std.concurrency? IIRC, those are never explicitly joined. Is catching Throwable in the spawned thread required in order to get stuff like AssertErrors printed?

Unfortunately yes.  I suppose std.concurency could do something fancy to propagate uncaught exceptions the thread's owner as a message (similar to the LinkTerminated message) but it doesn't do so now.