]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid deadlock in Utilities:MPI_InitFinalize when an exception is being thrown.
authorTimo Heister <timo.heister@gmail.com>
Sun, 6 Feb 2011 15:57:49 +0000 (15:57 +0000)
committerTimo Heister <timo.heister@gmail.com>
Sun, 6 Feb 2011 15:57:49 +0000 (15:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@23295 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/utilities.cc

index 4af1ce1fc4eff55884eba0aefc19e80ef3d00fb3..e96654b33699425c8ab6b8de685236c79ee8c760 100644 (file)
@@ -809,7 +809,18 @@ namespace Utilities
       MPI_Initialized(&MPI_has_been_started);
       if (program_uses_mpi() == true && owns_mpi == true &&
          MPI_has_been_started != 0)
-       mpi_err = MPI_Finalize();
+       {
+         if (std::uncaught_exception())
+           {    
+             std::cerr << "ERROR: Uncaught exception in MPI_InitFinalize on proc "
+                       << get_this_mpi_process(MPI_COMM_WORLD)
+                       << ". Skipping MPI_Finalize() to avoid a deadlock."
+                       << std::endl;
+           }
+         else
+           mpi_err = MPI_Finalize();
+       }
+      
 
       AssertThrow (mpi_err == 0,
                   ExcMessage ("An error occurred while calling MPI_Finalize()"));

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.