[Mpi-forum] C++ issues

N.M. Maclaren nmm1 at cam.ac.uk
Fri Jun 29 07:17:26 CDT 2012


On Jun 29 2012, Jeff Squyres wrote:
>
> 2. I have a dim recollection of someone saying that you can't always 
> replace MPI::ERRORS_THROW_EXCEPTIONS with a user-defined error handler 
> that throws an exception. Aside from the fact that MPI implementations 
> need to ensure that they can transparently pass exceptions (e.g., compile 
> a C-based MPI implementation with 
> --allow-passing-cxx-exceptions-through-c-functions types of compiler 
> flags), is my faulty memory remembering a real issue? I have a dim 
> recollection that it may have been Darius or Dave G. who brought up this 
> issue...?
>
>If this is a real issue, do we need to provide MPI_ERRORS_THROW_EXCEPTIONS?

I don't think that I did, but it is a real issue.  It is undefined behaviour
of the worst kind to throw a C++ exception where there is a Fortran
procedure in the call chain between the throw and the catch, and undefined
behaviour of a seriously nasty kind when there is a C one.  This has two
consequences:

    1) You can't replace MPI_ERRORS_THROW_EXCEPTIONS by a user-written
hander, and

    2) You can't define MPI_ERRORS_THROW_EXCEPTIONS in even vaguely
standard C or Fortran using user-written handlers.

Sorry, but that should be terminated with maximum prejudice.  It always
was well-defined only for pure C++ code.

[ The reason that it applies to C intermediates as well is that the C
code may break the data structures used for the C++ stack unwinding.
Most CURRENT compilers won't, but I have used ones that did, and it
may well happen if you mix C and C++ compilers from different vendors,
even today. ]


Regards,
Nick Maclaren.




More information about the mpi-forum mailing list