[phobos] parallelism segfaults

David Simcha dsimcha at gmail.com
Wed Sep 14 10:03:58 PDT 2011


How about this:  Could we send all daemon threads hardware exceptions after
joinAll()?  In the vast majority of cases, locks will be scoped, either
through synchronized blocks or simple scope(exit) mutex.unlock() type
statements.  If they're not then they should be.  (If any still aren't in
std.parallelism then I'll fix this.  I originally made a few non-scoped
around code that couldn't throw, but this was silly and I think I changed
all of them.)  This way daemon threads terminate immediately, locks get
released if the code's well-written,
and if you **really** need to do some cleanup, you can catch the exception.

On Wed, Sep 14, 2011 at 1:04 AM, Sean Kelly <sean at invisibleduck.org> wrote:

> On Sep 13, 2011, at 11:59 AM, Martin Nowak wrote:
>
> > I've had a look the core dumps from the sometimes failing std.parallelism
> test.
> > The issue is one of having daemon threads running while the GC is
> unmapping memory.
> > Usually this goes unnoticed because the parallelism threads wait in a
> work queue condition.
> > Sometimes a daemon thread is awakening from it's GC suspend handler after
> memory was already
> > freed. This issue is already mentioned in a comment at gc_term.
> >
> >
> > Thread  obj = Thread.getThis();
> >
> > ...
> > suspend
> > ...
> >
> > if( obj && !obj.m_lock ) // <- segfault
> >
> >
> > I think we should bluntly kill daemon threads after thread_joinAll.
>
> One issue with this is that if these threads held any locks accessed during
> later parts of the cleanup (the GC lock, module-level locks accessed in
> static dtors, etc), the app could hang instead of shutting down cleanly.  If
> the threads are forcibly terminated then it would really have to be after
> these cleanup steps occurred, but by then Bad Things could already be
> happening because module dtors have been run and the GC is terminated.
>
> Since daemon threads are an explicit choice made by the user, I hope that
> they have also considered how to notify them to terminate cleanly (as one
> does in C/C++ where daemon threads are the default).  The best thing is
> really to build this into the relevant module dtor.  There's also
> Runtime.isHalting if someone can present a case to un-deprecate it.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20110914/e02d5621/attachment.html>


More information about the phobos mailing list