From 6cf2ed1fff14ce0182a80ba30d332b2245b63423 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Thu, 18 Feb 2021 01:10:37 +0100 Subject: [PATCH] Die when attempting to free predefined operators. We used to just ignore that --- src/smpi/bindings/smpi_pmpi_op.cpp | 2 ++ src/smpi/include/smpi_op.hpp | 5 +++-- src/smpi/mpi/smpi_op.cpp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/smpi/bindings/smpi_pmpi_op.cpp b/src/smpi/bindings/smpi_pmpi_op.cpp index 80886a914f..e90a6ba99b 100644 --- a/src/smpi/bindings/smpi_pmpi_op.cpp +++ b/src/smpi/bindings/smpi_pmpi_op.cpp @@ -22,6 +22,8 @@ int PMPI_Op_free(MPI_Op * op) { CHECK_NULL(1, MPI_ERR_ARG, op) CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, *op) + if((*op)->is_predefined()) + return MPI_ERR_OP; simgrid::smpi::Op::unref(op); *op = MPI_OP_NULL; return MPI_SUCCESS; diff --git a/src/smpi/include/smpi_op.hpp b/src/smpi/include/smpi_op.hpp index 310822f98d..a267f54adc 100644 --- a/src/smpi/include/smpi_op.hpp +++ b/src/smpi/include/smpi_op.hpp @@ -17,11 +17,12 @@ class Op : public F2C{ bool is_commutative_; bool is_fortran_op_ = false; int refcount_ = 1; - bool predefined_; + bool is_predefined_; public: - Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), predefined_(predefined) {} + Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), is_predefined_(predefined) {} bool is_commutative() const { return is_commutative_; } + bool is_predefined() const { return is_predefined_; } bool is_fortran_op() const { return is_fortran_op_; } // tell that we were created from fortran, so we need to translate the type to fortran when called void set_fortran_op() { is_fortran_op_ = true; } diff --git a/src/smpi/mpi/smpi_op.cpp b/src/smpi/mpi/smpi_op.cpp index bac540c938..f2e3d7c25e 100644 --- a/src/smpi/mpi/smpi_op.cpp +++ b/src/smpi/mpi/smpi_op.cpp @@ -270,7 +270,7 @@ void Op::ref(){ void Op::unref(MPI_Op* op){ if((*op)!=MPI_OP_NULL){ (*op)->refcount_--; - if ((*op)->refcount_ == 0 && not (*op)->predefined_) + if ((*op)->refcount_ == 0 && not (*op)->is_predefined_) delete(*op); } } -- 2.20.1