Skip to content

Commit 394f73c

Browse files
lifflandernlslatt
authored andcommitted
#2478: runtime: free the MPI error handler properly to avoid leaking
1 parent 4e31dae commit 394f73c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/vt/runtime/runtime.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ bool Runtime::finalize(bool const force_now, bool const disable_sig) {
541541
}
542542

543543
MPI_Barrier(comm);
544+
MPI_Errhandler_free(&err_handler_);
544545

545546
theContext = nullptr; // used in some state checks
546547
context = nullptr; // "use" to avoid warning
@@ -1077,9 +1078,8 @@ namespace {
10771078
}
10781079

10791080
void Runtime::initializeErrorHandlers() {
1080-
MPI_Errhandler err_handler = 0;
1081-
MPI_Comm_create_errhandler(&mpiErrorHandler, &err_handler);
1082-
MPI_Comm_set_errhandler(theContext->getComm(), err_handler);
1081+
MPI_Comm_create_errhandler(&mpiErrorHandler, &err_handler_);
1082+
MPI_Comm_set_errhandler(theContext->getComm(), err_handler_);
10831083
}
10841084

10851085
void Runtime::initializeOptionalComponents() {

src/vt/runtime/runtime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ struct Runtime {
458458
std::unique_ptr<component::ComponentPack> p_;
459459
std::unique_ptr<arguments::ArgConfig> arg_config_;
460460
arguments::AppConfig const* app_config_; /**< App config during startup */
461+
MPI_Errhandler err_handler_ = 0;
461462
};
462463

463464
}} /* end namespace vt::runtime */

0 commit comments

Comments
 (0)