Commit a96ac72e authored by Wesley Bland's avatar Wesley Bland Committed by Huiwei Lu
Browse files

Don't free a request if it still pending



If we had a failure that caused a request to be pending, we were freeing
the request before calling the error handler. That caused segfaults. Now
we switch the ordering of the two to avoid that.

This also moves the assignment of the status_ptr to be a little earlier
to avoid another segfault.
Signed-off-by: default avatarHuiwei Lu <huiweilu@mcs.anl.gov>
parent 47ac6f6b
......@@ -60,16 +60,16 @@ int MPIR_Test_impl(MPI_Request *request, int *flag, MPI_Status *status)
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
if (MPID_Request_is_complete(request_ptr)) {
if (MPID_Request_is_pending_failure(request_ptr)) {
*flag = TRUE;
mpi_errno = request_ptr->status.MPI_ERROR;
goto fn_fail;
} else if (MPID_Request_is_complete(request_ptr)) {
mpi_errno = MPIR_Request_complete(request, request_ptr, status,
&active_flag);
*flag = TRUE;
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* Fall through to the exit */
} else if (MPID_Request_is_pending_failure(request_ptr)) {
*flag = TRUE;
mpi_errno = request_ptr->status.MPI_ERROR;
goto fn_fail;
}
fn_exit:
......
......@@ -168,7 +168,12 @@ int MPI_Testany(int count, MPI_Request array_of_requests[], int *indx,
status);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
if (request_ptrs[i] != NULL && MPID_Request_is_complete(request_ptrs[i]))
if (request_ptrs[i] != NULL && MPID_Request_is_pending_failure(request_ptrs[i])) {
mpi_errno = request_ptrs[i]->status.MPI_ERROR;
*flag = TRUE;
*indx = i;
goto fn_fail;
} else if (request_ptrs[i] != NULL && MPID_Request_is_complete(request_ptrs[i]))
{
mpi_errno = MPIR_Request_complete(&array_of_requests[i],
request_ptrs[i],
......@@ -183,11 +188,6 @@ int MPI_Testany(int count, MPI_Request array_of_requests[], int *indx,
{
n_inactive += 1;
}
} else if (request_ptrs[i] != NULL && MPID_Request_is_pending_failure(request_ptrs[i])) {
mpi_errno = request_ptrs[i]->status.MPI_ERROR;
*flag = TRUE;
*indx = i;
goto fn_fail;
}
}
......
......@@ -169,9 +169,16 @@ int MPI_Testsome(int incount, MPI_Request array_of_requests[], int *outcount,
array_of_statuses);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
}
if (request_ptrs[i] != NULL && MPID_Request_is_complete(request_ptrs[i]))
{
status_ptr = (array_of_statuses != MPI_STATUSES_IGNORE) ? &array_of_statuses[n_active] : MPI_STATUS_IGNORE;
status_ptr = (array_of_statuses != MPI_STATUSES_IGNORE) ? &array_of_statuses[n_active] : MPI_STATUS_IGNORE;
if (request_ptrs[i] != NULL && MPID_Request_is_pending_failure(request_ptrs[i])) {
mpi_errno = MPI_ERR_IN_STATUS;
array_of_indices[n_active] = i;
n_active += 1;
rc = request_ptrs[i]->status.MPI_ERROR;
if (status_ptr != MPI_STATUS_IGNORE) {
status_ptr->MPI_ERROR = rc;
}
} else if (request_ptrs[i] != NULL && MPID_Request_is_complete(request_ptrs[i])) {
rc = MPIR_Request_complete(&array_of_requests[i], request_ptrs[i],
status_ptr, &active_flag);
if (active_flag)
......@@ -197,12 +204,6 @@ int MPI_Testsome(int incount, MPI_Request array_of_requests[], int *outcount,
request_ptrs[i] = NULL;
n_inactive += 1;
}
} else if (request_ptrs[i] != NULL && MPID_Request_is_pending_failure(request_ptrs[i])) {
mpi_errno = MPI_ERR_IN_STATUS;
array_of_indices[n_active] = i;
n_active += 1;
rc = request_ptrs[i]->status.MPI_ERROR;
status_ptr->MPI_ERROR = rc;
}
}
......
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