On Wed, Aug 21, 2013 at 12:31 PM, Roy Stogner <royst...@ices.utexas.edu>
wrote:
>
>
> On Wed, 21 Aug 2013, John Peterson wrote:
>
>> and if LibMeshInit's destructor detects an uncaught_exception, it
>> could call std::terminate manually.
>
>
> I don't know if manual std::terminate() is kosher, and it definitely
> shouldn't be necessary; if there's an uncaught exception then we'll
> get to the terminate handler automatically.

If you believe this random web page [0], "std::terminate() may also be
called directly from the program", but I certainly agree with you that the
LibMeshInit destructor doesn't need to (and shouldn't be relied upon to) do
anything special with regard to uncaught exceptions.

> Sadly, for implementations where terminate gets called *after* a stack
> unwind we have a different problem: the stack trace we print out in
> our terminate handler will be empty.

Agreed.

>> Thoughts?
>
> To fix the "no MPI Abort when the stack isn't unwound" case: Check
> MPI_Initialized() in our terminate handler, call MPI_Abort() from
> there if it's true?

Looks like LibMeshInit's destructor currently only checks #if
defined(LIBMESH_HAVE_MPI), but I agree that checking MPI_Initialized()
would be more thorough.

> To fix the "no stack trace when the stack is unwound" case: move the
> print_trace back from our terminate handler to the libmesh_error()

The libmesh_error() macro already calls libMesh::print_trace() on one
processor jobs.  It doesn't do print anything for parallel jobs, but we
could make it do so, this was my idea in the patch I sent you off-list a
few days back (attached).  So I'd remove libmesh_write_traceout() from our
error handler as well if we apply this patch...

> macro?  But this isn't a perfect fix, since we would lose traces from
> other thrown exceptions.  Perhaps we could somehow keep our terminate
> handler printing traces in cases where the uncaught exception isn't
> from one of our macros?

You mean exceptions thrown from standard library routines?  If
std::uncaught_exception() == true, can you get access to the uncaught
exception in any way?  If yes I guess you could try dynamic_cast'ing it to
one of ours...

[0]: http://en.cppreference.com/w/cpp/error/terminate

-- 
John

Attachment: 0001-Write-tracefiles-from-libmesh_error-when-running-in-.patch
Description: Binary data

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to