From 95bf8700551f110b643cae1bafbfeb8a4ab68e68 Mon Sep 17 00:00:00 2001 From: Rolf vandeVaart Date: Wed, 29 Oct 2008 15:15:37 +0000 Subject: [PATCH] Fix the allocation for the pointers to the btl structures. We were only allocating one whereas we would typically need one per interface. Most of the time we got lucky and we happily trundled over unallocated memory. But with enough interfaces, we would get a SEGV. Also add include to fix compilation with static libs. This commit was SVN r19845. --- ompi/mca/btl/sctp/btl_sctp_component.c | 9 +++++++-- ompi/mca/btl/sctp/btl_sctp_utils.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ompi/mca/btl/sctp/btl_sctp_component.c b/ompi/mca/btl/sctp/btl_sctp_component.c index ac164c3c3d..e7cf50b88b 100644 --- a/ompi/mca/btl/sctp/btl_sctp_component.c +++ b/ompi/mca/btl/sctp/btl_sctp_component.c @@ -10,6 +10,7 @@ * 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) 2008 Sun Microsystems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -492,8 +493,12 @@ static int mca_btl_sctp_component_create_instance(void) return OMPI_ERROR; } - /* allocate memory for btl */ - mca_btl_sctp_component.sctp_btls = (mca_btl_sctp_module_t **)malloc(sizeof(mca_btl_sctp_module_t*)); + /* Allocate memory for btl pointers. This may be more space then + we need as some of the interfaces may get filtered out by the + if_include and if_exclude parameters. But that is just a few + unused pointers. */ + mca_btl_sctp_component.sctp_btls = + (mca_btl_sctp_module_t **)malloc(if_count * sizeof(mca_btl_sctp_module_t*)); if(NULL == mca_btl_sctp_component.sctp_btls) { return OMPI_ERR_OUT_OF_RESOURCE; } diff --git a/ompi/mca/btl/sctp/btl_sctp_utils.c b/ompi/mca/btl/sctp/btl_sctp_utils.c index 43170e0799..918acef6ae 100644 --- a/ompi/mca/btl/sctp/btl_sctp_utils.c +++ b/ompi/mca/btl/sctp/btl_sctp_utils.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,6 +24,7 @@ #include "btl_sctp_utils.h" +#include "ompi/mca/btl/base/btl_base_error.h" /** * struct sockaddr_in mca_btl_sctp_utils_sockaddr_from_frag