From f08433c1e1d6381ac2e92dffd0e6f86547c441d6 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 10 Jan 2011 21:12:27 +0000 Subject: [PATCH] Fixes trac:2669. Apparently, gcc 4.4.x and 4.5.x complain about the ''possibility'' of us calling free() on a non-heap variable. We know that this case can never happen because the refcount will absolutely not go to zero here. We think it may be gcc being a bit too aggressive on the warnings. However, since this happens with gcc 4.4.x and 4.5.x, and since gcc 4.5.x ship in RHEL6 and Fedora 14 (and others), someone '''will''' complain about this in the future, so we might as well code around it so that we don't have to keep explaining "despite the warning, it's really ok." The workaround is pretty simple: just OBJ_RELEASE the values from ompi_mpi_comm_parent before it is re-assigned to the new intercommunicator. Then the compiler's static code analysis can't possibly tell that it's not a heap variable, and we're ok. So yes, we are still calling OBJ_RELEASE on a non-heap variable. But free() '''will never be called''' on it because of the refcount. This commit was SVN r24214. The following Trac tickets were found above: Ticket 2669 --> https://svn.open-mpi.org/trac/ompi/ticket/2669 --- ompi/mca/dpm/orte/dpm_orte.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ompi/mca/dpm/orte/dpm_orte.c b/ompi/mca/dpm/orte/dpm_orte.c index 39932093b9..ed004db7bc 100644 --- a/ompi/mca/dpm/orte/dpm_orte.c +++ b/ompi/mca/dpm/orte/dpm_orte.c @@ -1013,10 +1013,6 @@ static int dyn_init(void) int root=0, rc; bool send_first = true; ompi_communicator_t *newcomm=NULL; - ompi_group_t *group = NULL; - ompi_errhandler_t *errhandler = NULL; - - ompi_communicator_t *oldcomm; /* if env-variable is set, we are a dynamically spawned * child - parse port and call comm_connect_accept */ @@ -1035,21 +1031,17 @@ static int dyn_init(void) return rc; } - /* Set the parent communicator */ - ompi_mpi_comm_parent = newcomm; - /* originally, we set comm_parent to comm_null (in comm_init), * now we have to decrease the reference counters to the according * objects */ - - oldcomm = &ompi_mpi_comm_null.comm; - OBJ_RELEASE(oldcomm); - group = &ompi_mpi_group_null.group; - OBJ_RELEASE(group); - errhandler = &ompi_mpi_errors_are_fatal.eh; - OBJ_RELEASE(errhandler); - + OBJ_RELEASE(ompi_mpi_comm_parent->c_local_group); + OBJ_RELEASE(ompi_mpi_comm_parent->error_handler); + OBJ_RELEASE(ompi_mpi_comm_parent); + + /* Set the parent communicator */ + ompi_mpi_comm_parent = newcomm; + /* Set name for debugging purposes */ snprintf(newcomm->c_name, MPI_MAX_OBJECT_NAME, "MPI_COMM_PARENT"); newcomm->c_flags |= OMPI_COMM_NAMEISSET;