Commit 9ff9a4e6 authored by Rob Latham's avatar Rob Latham
Browse files

avoid segfault when calling built-in error handler



we were not correctly handling the case where the error handler
MPI_ERRORS_ARE_FATAL was called.  credit Lisandro Dalcin with finidng
the issue.
Signed-off-by: default avatarJunchao Zhang <jczhang@mcs.anl.gov>
parent b3edcb53
...@@ -178,6 +178,12 @@ void MPIR_Err_get_string( int, char *, int, MPIR_Err_get_class_string_func_t ); ...@@ -178,6 +178,12 @@ void MPIR_Err_get_string( int, char *, int, MPIR_Err_get_class_string_func_t );
int MPIR_Err_set_msg( int code, const char *msg_string ); int MPIR_Err_set_msg( int code, const char *msg_string );
/* This routine is called when there is a fatal error. Now public because file
* error handling is defined in a separate file from comm and win, but all
* three need to call it */
void MPIR_Handle_fatal_error(struct MPID_Comm *comm_ptr,
const char fcname[], int errcode);
#define MPIR_ERR_CLASS_MASK 0x0000007f #define MPIR_ERR_CLASS_MASK 0x0000007f
#define MPIR_ERR_CLASS_SIZE 128 #define MPIR_ERR_CLASS_SIZE 128
#define MPIR_ERR_GET_CLASS(mpi_errno_) (mpi_errno_ & MPIR_ERR_CLASS_MASK) #define MPIR_ERR_GET_CLASS(mpi_errno_) (mpi_errno_ & MPIR_ERR_CLASS_MASK)
......
...@@ -117,7 +117,6 @@ static int did_err_init = FALSE; /* helps us solve a bootstrapping problem */ ...@@ -117,7 +117,6 @@ static int did_err_init = FALSE; /* helps us solve a bootstrapping problem */
with a valid value. */ with a valid value. */
static int checkValidErrcode( int, const char [], int * ); static int checkValidErrcode( int, const char [], int * );
static void handleFatalError( MPID_Comm *, const char [], int );
#if MPICH_ERROR_MSG_LEVEL >= MPICH_ERROR_MSG_ALL #if MPICH_ERROR_MSG_LEVEL >= MPICH_ERROR_MSG_ALL
static int ErrGetInstanceString( int, char [], int ); static int ErrGetInstanceString( int, char [], int );
...@@ -249,7 +248,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[], ...@@ -249,7 +248,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[],
{ {
/* for whatever reason, we aren't initialized (perhaps error /* for whatever reason, we aren't initialized (perhaps error
during MPI_Init) */ during MPI_Init) */
handleFatalError(MPIR_Process.comm_world, fcname, errcode); MPIR_Handle_fatal_error(MPIR_Process.comm_world, fcname, errcode);
return MPI_ERR_INTERN; return MPI_ERR_INTERN;
} }
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
...@@ -275,7 +274,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[], ...@@ -275,7 +274,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[],
/* --BEGIN ERROR HANDLING-- */ /* --BEGIN ERROR HANDLING-- */
if (MPIR_Err_is_fatal(errcode) || comm_ptr == NULL) { if (MPIR_Err_is_fatal(errcode) || comm_ptr == NULL) {
/* Calls MPID_Abort */ /* Calls MPID_Abort */
handleFatalError( comm_ptr, fcname, errcode ); MPIR_Handle_fatal_error( comm_ptr, fcname, errcode );
/* never get here */ /* never get here */
} }
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
...@@ -292,7 +291,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[], ...@@ -292,7 +291,7 @@ int MPIR_Err_return_comm( MPID_Comm *comm_ptr, const char fcname[],
if (errhandler == NULL || errhandler->handle == MPI_ERRORS_ARE_FATAL) { if (errhandler == NULL || errhandler->handle == MPI_ERRORS_ARE_FATAL) {
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr); MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* Calls MPID_Abort */ /* Calls MPID_Abort */
handleFatalError( comm_ptr, fcname, errcode ); MPIR_Handle_fatal_error( comm_ptr, fcname, errcode );
/* never get here */ /* never get here */
} }
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
...@@ -365,7 +364,7 @@ int MPIR_Err_return_win( MPID_Win *win_ptr, const char fcname[], int errcode ) ...@@ -365,7 +364,7 @@ int MPIR_Err_return_win( MPID_Win *win_ptr, const char fcname[], int errcode )
win_ptr == NULL || win_ptr->errhandler == NULL || win_ptr == NULL || win_ptr->errhandler == NULL ||
win_ptr->errhandler->handle == MPI_ERRORS_ARE_FATAL) { win_ptr->errhandler->handle == MPI_ERRORS_ARE_FATAL) {
/* Calls MPID_Abort */ /* Calls MPID_Abort */
handleFatalError( NULL, fcname, errcode ); MPIR_Handle_fatal_error( NULL, fcname, errcode );
} }
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
...@@ -432,8 +431,7 @@ static void CombineSpecificCodes( int, int, int ); ...@@ -432,8 +431,7 @@ static void CombineSpecificCodes( int, int, int );
static const char *get_class_msg( int ); static const char *get_class_msg( int );
/* --BEGIN ERROR HANDLING-- */ /* --BEGIN ERROR HANDLING-- */
/* This routine is called when there is a fatal error */ void MPIR_Handle_fatal_error( MPID_Comm *comm_ptr,
static void handleFatalError( MPID_Comm *comm_ptr,
const char fcname[], int errcode ) const char fcname[], int errcode )
{ {
/* Define length of the the maximum error message line (or string with /* Define length of the the maximum error message line (or string with
......
...@@ -98,6 +98,9 @@ int MPI_File_call_errhandler(MPI_File fh, int errorcode) ...@@ -98,6 +98,9 @@ int MPI_File_call_errhandler(MPI_File fh, int errorcode)
goto fn_exit; goto fn_exit;
} }
if (e->handle == MPI_ERRORS_ARE_FATAL) {
MPIR_Handle_fatal_error(NULL, "MPI_File_call_errhandler", errorcode);
}
switch (e->language) { switch (e->language) {
case MPID_LANG_C: case MPID_LANG_C:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment