Assert failures in threads

Sean Kelly sean at invisibleduck.org
Tue Jul 9 10:39:59 PDT 2013


On Jul 1, 2013, at 4:04 AM, Joseph Rushton Wakeling <joseph.wakeling at 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.


More information about the Digitalmars-d-learn mailing list