From 1748f44147b424b3acc3153d4027e96eeab0609e Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 18 Feb 2016 13:48:41 -0800 Subject: [PATCH] Stop a segfault that results in zombied processes by checking for NULL prior to object release --- orte/mca/iof/hnp/iof_hnp.c | 16 ++++++++++++---- orte/mca/iof/orted/iof_orted.c | 16 ++++++++++++---- orte/test/mpi/abort.c | 1 + 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/orte/mca/iof/hnp/iof_hnp.c b/orte/mca/iof/hnp/iof_hnp.c index 4f13130946..c3e487c369 100644 --- a/orte/mca/iof/hnp/iof_hnp.c +++ b/orte/mca/iof/hnp/iof_hnp.c @@ -379,19 +379,27 @@ static int hnp_close(const orte_process_name_t* peer, OPAL_LIST_FOREACH(proct, &mca_iof_hnp_component.procs, orte_iof_proc_t) { if (OPAL_EQUAL == orte_util_compare_name_fields(mask, &proct->name, peer)) { if (ORTE_IOF_STDIN & source_tag) { - OBJ_RELEASE(proct->stdin); + if (NULL != proct->stdin) { + OBJ_RELEASE(proct->stdin); + } ++cnt; } if (ORTE_IOF_STDOUT & source_tag) { - OBJ_RELEASE(proct->revstdout); + if (NULL != proct->revstdout) { + OBJ_RELEASE(proct->revstdout); + } ++cnt; } if (ORTE_IOF_STDERR & source_tag) { - OBJ_RELEASE(proct->revstderr); + if (NULL != proct->revstderr) { + OBJ_RELEASE(proct->revstderr); + } ++cnt; } if (ORTE_IOF_STDDIAG & source_tag) { - OBJ_RELEASE(proct->revstddiag); + if (NULL != proct->revstddiag) { + OBJ_RELEASE(proct->revstddiag); + } ++cnt; } /* if we closed them all, then remove this proc */ diff --git a/orte/mca/iof/orted/iof_orted.c b/orte/mca/iof/orted/iof_orted.c index 4902562bdd..e90ac1d69b 100644 --- a/orte/mca/iof/orted/iof_orted.c +++ b/orte/mca/iof/orted/iof_orted.c @@ -270,19 +270,27 @@ static int orted_close(const orte_process_name_t* peer, OPAL_LIST_FOREACH(proct, &mca_iof_orted_component.procs, orte_iof_proc_t) { if (OPAL_EQUAL == orte_util_compare_name_fields(mask, &proct->name, peer)) { if (ORTE_IOF_STDIN & source_tag) { - OBJ_RELEASE(proct->stdin); + if (NULL != proct->stdin) { + OBJ_RELEASE(proct->stdin); + } ++cnt; } if (ORTE_IOF_STDOUT & source_tag) { - OBJ_RELEASE(proct->revstdout); + if (NULL != proct->revstdout) { + OBJ_RELEASE(proct->revstdout); + } ++cnt; } if (ORTE_IOF_STDERR & source_tag) { - OBJ_RELEASE(proct->revstderr); + if (NULL != proct->revstderr) { + OBJ_RELEASE(proct->revstderr); + } ++cnt; } if (ORTE_IOF_STDDIAG & source_tag) { - OBJ_RELEASE(proct->revstddiag); + if (NULL != proct->revstddiag) { + OBJ_RELEASE(proct->revstddiag); + } ++cnt; } /* if we closed them all, then remove this proc */ diff --git a/orte/test/mpi/abort.c b/orte/test/mpi/abort.c index e84ab4b97f..79448b9d80 100644 --- a/orte/test/mpi/abort.c +++ b/orte/test/mpi/abort.c @@ -34,6 +34,7 @@ int main(int argc, char* argv[]) MPI_Abort(MPI_COMM_WORLD, errcode); } else { errcode = 0; + sleep(99999999); } }