From 448b2821fffaa33bd0b2f036dee9f2a42d66a160 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Mon, 27 Jul 2015 11:36:16 -0400 Subject: [PATCH] avoid dereferencing empty std::vectors --- .../deal.II/lac/parallel_vector.templates.h | 32 +++++++++++-------- source/base/partitioner.cc | 5 +-- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/deal.II/lac/parallel_vector.templates.h b/include/deal.II/lac/parallel_vector.templates.h index 0230a8e926..89b280dfc9 100644 --- a/include/deal.II/lac/parallel_vector.templates.h +++ b/include/deal.II/lac/parallel_vector.templates.h @@ -633,19 +633,25 @@ namespace parallel // make sure that there are not outstanding requests from updating // ghost values or compress int flag = 1; - int ierr = MPI_Testall (update_ghost_values_requests.size(), - &update_ghost_values_requests[0], - &flag, MPI_STATUSES_IGNORE); - Assert (ierr == MPI_SUCCESS, ExcInternalError()); - Assert (flag == 1, - ExcMessage("MPI found unfinished update_ghost_values() requests" - "when calling swap, which is not allowed")); - ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], - &flag, MPI_STATUSES_IGNORE); - Assert (ierr == MPI_SUCCESS, ExcInternalError()); - Assert (flag == 1, - ExcMessage("MPI found unfinished compress() requests " - "when calling swap, which is not allowed")); + if (update_ghost_values_requests.size()>0) + { + int ierr = MPI_Testall (update_ghost_values_requests.size(), + &update_ghost_values_requests[0], + &flag, MPI_STATUSES_IGNORE); + Assert (ierr == MPI_SUCCESS, ExcInternalError()); + Assert (flag == 1, + ExcMessage("MPI found unfinished update_ghost_values() requests" + "when calling swap, which is not allowed")); + } + if (compress_requests.size()>0) + { + int ierr = MPI_Testall (compress_requests.size(), &compress_requests[0], + &flag, MPI_STATUSES_IGNORE); + Assert (ierr == MPI_SUCCESS, ExcInternalError()); + Assert (flag == 1, + ExcMessage("MPI found unfinished compress() requests " + "when calling swap, which is not allowed")); + } } #endif diff --git a/source/base/partitioner.cc b/source/base/partitioner.cc index 39240e1e4e..1b216a9d4e 100644 --- a/source/base/partitioner.cc +++ b/source/base/partitioner.cc @@ -281,8 +281,9 @@ namespace Utilities } AssertDimension (current_index_start, n_ghost_indices_data); - MPI_Waitall (import_requests.size(), &import_requests[0], - MPI_STATUSES_IGNORE); + if (import_requests.size()>0) + MPI_Waitall (import_requests.size(), &import_requests[0], + MPI_STATUSES_IGNORE); // transform import indices to local index space and compress // contiguous indices in form of ranges -- 2.39.5