From 036db91f3d0b6e07d436bd66f52a1f86d892230f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 14 Mar 2014 20:39:39 +0000 Subject: [PATCH] For the love of all that is holy, do not put 1MB arrays on the stack. This was causing JVMs to run out of stack space, and all manner of badness ensued. Instead, use the heap -- that's what it's there for. cmr=v1.7.5:reviewer=rhc:subject=make coll/ml use the heap for large debug array This commit was SVN r31073. --- ompi/mca/coll/ml/coll_ml_module.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ompi/mca/coll/ml/coll_ml_module.c b/ompi/mca/coll/ml/coll_ml_module.c index 47a0df5ce4..8efeb07e9c 100644 --- a/ompi/mca/coll/ml/coll_ml_module.c +++ b/ompi/mca/coll/ml/coll_ml_module.c @@ -2440,12 +2440,14 @@ static int mca_coll_ml_fill_in_route_tab(mca_coll_ml_topology_t *topo, ompi_comm #if OPAL_ENABLE_DEBUG #define COLL_ML_ROUTE_BUFF_SIZE (1024*1024) - { + /* Only bother creating the string if we're actually going to + print it out (i.e., if the verbose level is >= 10) */ + if (mca_coll_ml_component.verbose >= 10) { int ii, jj; - char buff[COLL_ML_ROUTE_BUFF_SIZE]; - char *output = buff; + char *buff, *output; - memset(buff, 0, COLL_ML_ROUTE_BUFF_SIZE); + output = buff = calloc(1, COLL_ML_ROUTE_BUFF_SIZE); + assert(NULL != output); sprintf(output, "ranks: "); @@ -2499,7 +2501,8 @@ static int mca_coll_ml_fill_in_route_tab(mca_coll_ml_topology_t *topo, ompi_comm } ML_VERBOSE(10, ("\nThe table is:\n============\n%s\n", buff)); - } + free(buff); + } while(0); #endif for (level = 0; level < topo->n_levels; ++level) {