Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add leak checking for info and errhandlers
authorAugustin Degomme <adegomme@gmail.com>
Tue, 2 Mar 2021 14:58:38 +0000 (15:58 +0100)
committerAugustin Degomme <adegomme@gmail.com>
Tue, 2 Mar 2021 22:37:13 +0000 (23:37 +0100)
src/smpi/bindings/smpi_pmpi_comm.cpp
src/smpi/include/smpi_info.hpp
src/smpi/mpi/smpi_errhandler.cpp
src/smpi/mpi/smpi_info.cpp

index 28aee04..0057999 100644 (file)
@@ -275,6 +275,7 @@ int PMPI_Errhandler_free(MPI_Errhandler* errhandler){
 int PMPI_Errhandler_create(MPI_Handler_function* function, MPI_Errhandler* errhandler){
   CHECK_NULL(2, MPI_ERR_ARG, errhandler)
   *errhandler=new simgrid::smpi::Errhandler(function);
+  (*errhandler)->add_f();
   return MPI_SUCCESS;
 }
 
index ef7c374..91aeaee 100644 (file)
@@ -20,8 +20,8 @@ class Info : public F2C{
   int refcount_ = 1;
 
 public:
-  Info() = default;
-  explicit Info(const Info* orig) : map_(orig->map_) {}
+  explicit Info() {this->add_f();}
+  explicit Info(const Info* orig) : map_(orig->map_) {this->add_f();}
   ~Info() override = default;
   void ref();
   static void unref(MPI_Info info);
index 6ed4b51..9e237d4 100644 (file)
@@ -45,11 +45,15 @@ void Errhandler::ref()
 }
 
 void Errhandler::unref(Errhandler* errhandler){
+  if(errhandler == MPI_ERRORS_ARE_FATAL || errhandler == MPI_ERRORS_RETURN)
+    return;
   errhandler->refcount_--;
   if(errhandler->refcount_==0){
+    F2C::free_f(errhandler->c2f());
     delete errhandler;
   }
 }
 
 }
+
 }
index bd68f4c..ed832a6 100644 (file)
@@ -17,6 +17,7 @@ void Info::ref()
 void Info::unref(Info* info){
   info->refcount_--;
   if(info->refcount_==0){
+    F2C::free_f(info->c2f());
     delete info;
   }
 }