-
Notifications
You must be signed in to change notification settings - Fork 300
libmesh_terminate(), for relatively-quiet exit via the terminate handler #4369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
This should accomodate users who need to exit suddenly (without manually unwinding a stack) and quietly (without distracting from their own exit output) while still cleaning up (so they don't get segfaults when dangling references to our custom output buffers interact with iostreams cleanup later).
We don't currently have libMesh infrastructure for testing output of lots of executable runs, so this will have to do until we get to MOOSE CI.
loganharbour
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me
|
|
||
| void libmesh_terminate_handler() | ||
| { | ||
| bool print_debug_info = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| bool print_debug_info = true; | |
| bool print_libmesh_info = true; |
I don't know the best name here but this feels a little better to me. We're still printing the std_ex.what() so it feels like we're still printing some debug info. And this boolean also controls more things than strictly debug info such as perf log output. Anyway this isn't a big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're actually not printing std_ex.what() if that gets set to off - TerminationException doesn't inherit from std::exception and doesn't even implement what().
"debug info" is a kind of bad name for something that includes the perf log, though, yeah. If this was a public-facing identifier or if this wasn't blocking a huge update I'd change it, but now that Logan reports it (plus a tiny MOOSE patch to use it) works for his segfault issues, I want to get this merged ASAP.
|
If I understand correctly, the idea here is to create an unlikely to be caught kind of exception so that the terminate handler is reached, but isn't it still implementation-defined whether the stack is unwound or not for an uncaught exception? I'm not against the change, just curious if there's any way to guarantee the stack won't be unwound. |
|
Job Coverage, step Generate coverage on 1693412 wanted to post the following: Coverage
Warnings
This comment will be updated on new commits. |
||||||||||||||||||||||||||
|
It is implementation-defined whether the stack will be unwound before an uncaught exception hits the terminate handler. In the case of unwinding ... damn, that's actually a problem (albeit a theoretical and pre-existing problem), isn't it? We'll hit all the Maybe we really just need to expose the terminate handler (or rather a terminate function with parameters that the handler function can call with default values)? But even that might not work! One process calls Maybe we could put critical cleanup into an MPI error handler callback? Hand that to |
No, I think I'm misunderstanding the docs. That error handler isn't for when an abort hits you, it's for when any MPI function associated with that communicator (including MPI_Abort) is about to return an error. So I'm again out of ideas. OpenMPI says it aborts processes via SIGTERM, so we could set a signal handler for that. With MPICH it looks like it might also be SIGTERM but it depends on process manager? Maybe what we ought to be doing here is using dumb pointers to manage our |
This should accommodate users who need to exit suddenly (without manually unwinding a stack) and quietly (without distracting from their own exit output) while still cleaning up (so they don't get segfaults when dangling references to our custom output buffers interact with iostreams cleanup later).