Per RFC fix several leaks in opal and ompi. Details below.
pml/v: - If vprotocol is not being used vprotocol_include_list is leaked. Assume vprotocol never takes ownership (see below) and always free the string. coll/ml: - (patch verified) calling mca_base_param_lookup_string after mca_base_param_reg_string is unnecessary. The call to mca_base_param_lookup_string causes the value returned by mca_base_param_reg_string to be leaked. - Need to free mca_coll_ml_component.config_file_name on component close. btl/openib: - calling mca_base_param_lookup_string after mca_base_param_reg_string is unnecessary. The call to mca_base_param_lookup_string causes the value returned by mca_base_param_reg_string to be leaked. vprotocol/base: - There was no way for pml/v to determine if vprotocol took ownership of vprotocol_include_list. Fix by always never ownership (use strdup). mca/base: - param_lookup will result in storage->stringval to be a newly allocated string if the mca parameter has a string value. ensure this string is always freed. cmr:v1.7 This commit was SVN r27569.
Этот коммит содержится в:
родитель
d6e9a14b14
Коммит
f3ce12e71a
@ -81,7 +81,6 @@ static int reg_string(const char* param_name,
|
|||||||
&mca_btl_openib_component.super.btl_version,
|
&mca_btl_openib_component.super.btl_version,
|
||||||
deprecated_param_name, true);
|
deprecated_param_name, true);
|
||||||
}
|
}
|
||||||
mca_base_param_lookup_string(index, &value);
|
|
||||||
|
|
||||||
if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) {
|
if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) {
|
||||||
opal_output(0, "Bad parameter value for parameter \"%s\"",
|
opal_output(0, "Bad parameter value for parameter \"%s\"",
|
||||||
|
@ -390,6 +390,8 @@ static int ml_open(void)
|
|||||||
cs->base_sequence_number = -1;
|
cs->base_sequence_number = -1;
|
||||||
cs->progress_is_busy = false;
|
cs->progress_is_busy = false;
|
||||||
|
|
||||||
|
mca_coll_ml_component.config_file_name = NULL;
|
||||||
|
|
||||||
/* load mca parametres */
|
/* load mca parametres */
|
||||||
rc = mca_coll_ml_register_params();
|
rc = mca_coll_ml_register_params();
|
||||||
if (OMPI_SUCCESS != rc) {
|
if (OMPI_SUCCESS != rc) {
|
||||||
@ -477,6 +479,12 @@ static int ml_close(void)
|
|||||||
|
|
||||||
mca_coll_ml_component_t *cs = &mca_coll_ml_component;
|
mca_coll_ml_component_t *cs = &mca_coll_ml_component;
|
||||||
|
|
||||||
|
/* Free the config file name (allocated by mca_coll_ml_register_params) */
|
||||||
|
if (NULL != mca_coll_ml_component.config_file_name) {
|
||||||
|
free (mca_coll_ml_component.config_file_name);
|
||||||
|
mca_coll_ml_component.config_file_name = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* There is not need to release/close resource if the
|
/* There is not need to release/close resource if the
|
||||||
* priority was set to zero */
|
* priority was set to zero */
|
||||||
if (cs->ml_priority <= 0) {
|
if (cs->ml_priority <= 0) {
|
||||||
|
@ -65,8 +65,6 @@ static int reg_string(const char* param_name,
|
|||||||
deprecated_param_name, true);
|
deprecated_param_name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
mca_base_param_lookup_string(index, &value);
|
|
||||||
|
|
||||||
if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) {
|
if (0 != (flags & REGSTR_EMPTY_OK) && 0 == strlen(value)) {
|
||||||
opal_output(0, "Bad parameter value for parameter \"%s\"",
|
opal_output(0, "Bad parameter value for parameter \"%s\"",
|
||||||
param_name);
|
param_name);
|
||||||
|
@ -67,6 +67,7 @@ static int mca_pml_v_component_open(void)
|
|||||||
int verbose;
|
int verbose;
|
||||||
int priority;
|
int priority;
|
||||||
char *vprotocol_include_list;
|
char *vprotocol_include_list;
|
||||||
|
int rc;
|
||||||
|
|
||||||
priority = mca_pml_v_param_register_int("priority", -1);
|
priority = mca_pml_v_param_register_int("priority", -1);
|
||||||
output = mca_pml_v_param_register_string("output", "stderr");
|
output = mca_pml_v_param_register_string("output", "stderr");
|
||||||
@ -84,7 +85,10 @@ static int mca_pml_v_component_open(void)
|
|||||||
|
|
||||||
V_OUTPUT_VERBOSE(500, "loaded");
|
V_OUTPUT_VERBOSE(500, "loaded");
|
||||||
|
|
||||||
return mca_vprotocol_base_open(vprotocol_include_list);
|
rc = mca_vprotocol_base_open(vprotocol_include_list);
|
||||||
|
free (vprotocol_include_list);
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mca_pml_v_component_close(void)
|
static int mca_pml_v_component_close(void)
|
||||||
|
@ -27,11 +27,11 @@ mca_pml_v_t mca_pml_v = {-1, 0, 0};
|
|||||||
int mca_vprotocol_base_open(char *vprotocol_include_list)
|
int mca_vprotocol_base_open(char *vprotocol_include_list)
|
||||||
{
|
{
|
||||||
OBJ_CONSTRUCT(&mca_vprotocol_base_components_available, opal_list_t);
|
OBJ_CONSTRUCT(&mca_vprotocol_base_components_available, opal_list_t);
|
||||||
mca_vprotocol_base_include_list = vprotocol_include_list;
|
if (NULL == vprotocol_include_list ||
|
||||||
if (NULL == mca_vprotocol_base_include_list ||
|
|
||||||
mca_vprotocol_base_include_list[0] == 0) {
|
mca_vprotocol_base_include_list[0] == 0) {
|
||||||
return OMPI_SUCCESS;
|
return OMPI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
mca_vprotocol_base_include_list = strdup (vprotocol_include_list);
|
||||||
return mca_base_components_open("vprotocol", 0,
|
return mca_base_components_open("vprotocol", 0,
|
||||||
mca_vprotocol_base_static_components,
|
mca_vprotocol_base_static_components,
|
||||||
&mca_vprotocol_base_components_available,
|
&mca_vprotocol_base_components_available,
|
||||||
|
@ -137,6 +137,7 @@ static void info_constructor(mca_base_param_info_t *p);
|
|||||||
static void info_destructor(mca_base_param_info_t *p);
|
static void info_destructor(mca_base_param_info_t *p);
|
||||||
static void syn_info_constructor(syn_info_t *si);
|
static void syn_info_constructor(syn_info_t *si);
|
||||||
static void syn_info_destructor(syn_info_t *si);
|
static void syn_info_destructor(syn_info_t *si);
|
||||||
|
static mca_base_param_type_t param_type_from_index (size_t index);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make the class instance for mca_base_param_t
|
* Make the class instance for mca_base_param_t
|
||||||
@ -514,11 +515,17 @@ int mca_base_param_set_string(int index, char *value)
|
|||||||
int mca_base_param_lookup_source(int index, mca_base_param_source_t *source, char **source_file)
|
int mca_base_param_lookup_source(int index, mca_base_param_source_t *source, char **source_file)
|
||||||
{
|
{
|
||||||
mca_base_param_storage_t storage;
|
mca_base_param_storage_t storage;
|
||||||
|
int rc;
|
||||||
if (param_lookup(index, &storage, source, source_file)) {
|
|
||||||
return OPAL_SUCCESS;
|
storage.stringval = NULL;
|
||||||
|
|
||||||
|
rc = param_lookup(index, &storage, source, source_file);
|
||||||
|
if (MCA_BASE_PARAM_TYPE_STRING == param_type_from_index (index) &&
|
||||||
|
NULL != storage.stringval) {
|
||||||
|
free (storage.stringval);
|
||||||
}
|
}
|
||||||
return OPAL_ERROR;
|
|
||||||
|
return rc ? OPAL_SUCCESS : OPAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1544,6 +1551,27 @@ static bool param_set_override(size_t index,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lookup the type of a parameter from an index
|
||||||
|
*/
|
||||||
|
static mca_base_param_type_t param_type_from_index (size_t index)
|
||||||
|
{
|
||||||
|
mca_base_param_t *array;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
/* Lookup the index and see if it's valid */
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
size = opal_value_array_get_size(&mca_base_params);
|
||||||
|
if (index > size) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
array = OPAL_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
|
||||||
|
|
||||||
|
return array[index].mbp_type;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lookup a parameter in multiple places
|
* Lookup a parameter in multiple places
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user