Protect against 0-byte allocations in carte_create and cart_sub.
cmr=v1.7.5:reviewer=jsquyres This commit was SVN r31146.
Этот коммит содержится в:
родитель
7adb137409
Коммит
dca2f0027e
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -10,6 +11,8 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014 Los Alamos National Security, LLC. All right
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -127,6 +130,15 @@ int mca_topo_base_cart_create(mca_topo_base_module_t *topo,
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't do any of the other initialization if we're not supposed
|
||||
to be part of the new communicator (because nnodes has been
|
||||
reset to 0, making things like index[nnodes-1] be junk).
|
||||
|
||||
JMS: This should really be refactored to use
|
||||
comm_create_group(), because ompi_comm_allocate() still
|
||||
complains about 0-byte mallocs in debug builds for 0-member
|
||||
groups. */
|
||||
if (num_procs > 0) {
|
||||
/* Copy the proc structure from the previous communicator over to
|
||||
the new one. The topology module is then able to work on this
|
||||
copy and rearrange it as it deems fit. */
|
||||
@ -140,6 +152,7 @@ int mca_topo_base_cart_create(mca_topo_base_module_t *topo,
|
||||
topo_procs[i] = ompi_group_peer_lookup(old_comm->c_local_group,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* allocate a new communicator */
|
||||
new_comm = ompi_comm_allocate(num_procs, 0);
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
||||
/*
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
@ -10,6 +11,8 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
* Additional copyrights may follow
|
||||
@ -120,6 +123,9 @@ int mca_topo_base_cart_sub (ompi_communicator_t* comm,
|
||||
cart->ndims = ndim;
|
||||
cart->dims = dorig;
|
||||
cart->periods = porig;
|
||||
|
||||
/* NTH: protect against a 0-byte alloc in the ndims = 0 case */
|
||||
if (ndim > 0) {
|
||||
cart->coords = (int*)malloc(sizeof(int) * ndim);
|
||||
if (NULL == cart->coords) {
|
||||
free(cart->periods);
|
||||
@ -137,11 +143,14 @@ int mca_topo_base_cart_sub (ompi_communicator_t* comm,
|
||||
rank %= nprocs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
temp_comm->c_topo = topo;
|
||||
temp_comm->c_topo->mtc.cart = cart;
|
||||
temp_comm->c_topo->reorder = false;
|
||||
temp_comm->c_flags |= OMPI_COMM_CART;
|
||||
}
|
||||
|
||||
*new_comm = temp_comm;
|
||||
|
||||
return MPI_SUCCESS;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user