Clean up and improve fatal error handling
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 7 Oct 2015 19:11:02 +0000 (22:11 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 22 Oct 2015 12:14:04 +0000 (14:14 +0200)
commit8d4ef61e8e373f203a57d400020b66aedda36ee5
tree75314d7a1cbf705180b6486211c49cbd5c1beddc
parent9abcc254befaf9ef41b237ccc43067d7b1377ca7
Clean up and improve fatal error handling

- Hide gmx_strerror() within fatalerror.cpp, and clean up the
  implementation.
- Move more error formatting responsibility into the fatal error handler
  in fatalerror.cpp, and make it use the shared formatting code in
  errorformat.h.  This has a side effect of providing automatic line
  wrapping for gmx_fatal().
- Move all output from gmx_abort() to the fatal error output routines.
- Centralize the handling of aborting the program on various error
  conditions to gmx_exit_on_fatal_error().
- Flush various streams before calling std::abort() to try to ensure
  that there is no buffered data left (such as the just-printed fatal
  error).
- Call std::abort() instead of std::exit() in cases where the
  application cannot be guaranteed to be in a clean state: std::exit()
  calls destructors for all global and static singleton objects, which
  can cause issues if, e.g., other threads are still executing code.
- Remove essentially unused code for handling errno in gmx_fatal().
  There was a single instance passing anything else except 0, and the
  way perror() was used would not produce anything useful in this case,
  either.

Change-Id: I0a4c458308cde0e149f986b321caa7cd5cbb1eca
src/gromacs/fileio/tngio.cpp
src/gromacs/gmxana/powerspect.cpp
src/gromacs/utility/basenetwork.cpp
src/gromacs/utility/errorformat.cpp
src/gromacs/utility/exceptions.cpp
src/gromacs/utility/exceptions.h
src/gromacs/utility/fatalerror.cpp
src/gromacs/utility/fatalerror.h
src/gromacs/utility/gmxassert.cpp