1
1
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
Этот коммит содержится в:
Jeff Squyres 2011-01-10 21:12:27 +00:00
родитель 11ffa854ff
Коммит f08433c1e1

Просмотреть файл

@ -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;