Skip to content

Commit 6033c0e

Browse files
committed
fix some memleak
avx_component module retain twice by avx_component_op_query and ompi_op_base_op_select function opal_common_ucx ucx tls and devices not free opal_patcher_base_framework not close Signed-off-by: wjjahah <[email protected]>
1 parent 3b92bb1 commit 6033c0e

File tree

4 files changed

+20
-35
lines changed

4 files changed

+20
-35
lines changed

ompi/mca/op/avx/op_avx_component.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,6 @@ avx_component_op_query(struct ompi_op_t *op, int *priority)
298298
}
299299
}
300300
#endif
301-
if( NULL != module->opm_fns[i] ) {
302-
OBJ_RETAIN(module);
303-
}
304-
if( NULL != module->opm_3buff_fns[i] ) {
305-
OBJ_RETAIN(module);
306-
}
307301
}
308302
break;
309303
case OMPI_OP_BASE_FORTRAN_LAND:

opal/mca/common/ucx/common_ucx.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
7373
{
7474
char *default_tls = "rc_verbs,ud_verbs,rc_mlx5,dc_mlx5,ud_mlx5,cuda_ipc,rocm_ipc";
7575
char *default_devices = "mlx*";
76+
char *old_str = NULL;
7677
int hook_index;
7778
int verbose_index;
7879
int progress_index;
@@ -102,17 +103,9 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
102103
&opal_common_ucx.opal_mem_hooks);
103104

104105
if (NULL == opal_common_ucx.tls) {
105-
// Extra level of string indirection needed to make ompi_info
106-
// happy since it will unload this library before the MCA base
107-
// cleans up the MCA vars. This will cause the string to go
108-
// out of scope unless we place the pointer to it on the heap.
109-
opal_common_ucx.tls = (char **) malloc(sizeof(char *));
110-
*opal_common_ucx.tls = NULL;
111-
}
112-
113-
if (NULL == *opal_common_ucx.tls) {
114-
*opal_common_ucx.tls = strdup(default_tls);
106+
opal_common_ucx.tls = strdup(default_tls);
115107
}
108+
old_str = opal_common_ucx.tls;
116109

117110
tls_index = mca_base_var_register(
118111
"opal", "opal_common", "ucx", "tls",
@@ -122,23 +115,21 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
122115
"For example, in order to exclude on shared memory and TCP transports, "
123116
"please set to '^posix,sysv,self,tcp,cma,knem,xpmem'.",
124117
MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE | MCA_BASE_VAR_FLAG_DWG,
125-
OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL, opal_common_ucx.tls);
118+
OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL, &opal_common_ucx.tls);
119+
free(old_str);
126120

127121
if (NULL == opal_common_ucx.devices) {
128-
opal_common_ucx.devices = (char**) malloc(sizeof(char*));
129-
*opal_common_ucx.devices = NULL;
130-
}
131-
132-
if (NULL == *opal_common_ucx.devices) {
133-
*opal_common_ucx.devices = strdup(default_devices);
122+
opal_common_ucx.devices = strdup(default_devices);
134123
}
124+
old_str = opal_common_ucx.tls;
135125

136126
devices_index = mca_base_var_register(
137127
"opal", "opal_common", "ucx", "devices",
138128
"List of device driver pattern names, which, if supported by UCX, will "
139129
"bump its priority above ob1. Special values: any (any available)",
140130
MCA_BASE_VAR_TYPE_STRING, NULL, 0, MCA_BASE_VAR_FLAG_SETTABLE | MCA_BASE_VAR_FLAG_DWG,
141-
OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL, opal_common_ucx.devices);
131+
OPAL_INFO_LVL_3, MCA_BASE_VAR_SCOPE_LOCAL, &opal_common_ucx.devices);
132+
free(old_str);
142133

143134
if (component) {
144135
mca_base_var_register_synonym(verbose_index, component->mca_project_name,
@@ -270,12 +261,12 @@ OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_
270261
int ret;
271262
#endif
272263

273-
if ((*opal_common_ucx.tls == NULL) || (*opal_common_ucx.devices == NULL)) {
264+
if ((opal_common_ucx.tls == NULL) || (opal_common_ucx.devices == NULL)) {
274265
opal_common_ucx_mca_var_register(NULL);
275266
}
276267

277-
is_any_tl = !strcmp(*opal_common_ucx.tls, "any");
278-
is_any_device = !strcmp(*opal_common_ucx.devices, "any");
268+
is_any_tl = !strcmp(opal_common_ucx.tls, "any");
269+
is_any_device = !strcmp(opal_common_ucx.devices, "any");
279270

280271
/* Check for special value "any" */
281272
if (is_any_tl && is_any_device) {
@@ -286,19 +277,19 @@ OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_
286277

287278
#if HAVE_DECL_OPEN_MEMSTREAM
288279
/* Split transports list */
289-
negate = ('^' == (*opal_common_ucx.tls)[0]);
290-
tl_list = opal_argv_split(*opal_common_ucx.tls + (negate ? 1 : 0), ',');
280+
negate = ('^' == (opal_common_ucx.tls)[0]);
281+
tl_list = opal_argv_split(opal_common_ucx.tls + (negate ? 1 : 0), ',');
291282
if (tl_list == NULL) {
292283
MCA_COMMON_UCX_VERBOSE(1, "failed to split tl list '%s', ucx is disabled",
293-
*opal_common_ucx.tls);
284+
opal_common_ucx.tls);
294285
goto out;
295286
}
296287

297288
/* Split devices list */
298-
device_list = opal_argv_split(*opal_common_ucx.devices, ',');
289+
device_list = opal_argv_split(opal_common_ucx.devices, ',');
299290
if (device_list == NULL) {
300291
MCA_COMMON_UCX_VERBOSE(1, "failed to split devices list '%s', ucx is disabled",
301-
*opal_common_ucx.devices);
292+
opal_common_ucx.devices);
302293
goto out_free_tl_list;
303294
}
304295

opal/mca/common/ucx/common_ucx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ typedef struct opal_common_ucx_module {
9191
int progress_iterations;
9292
int registered;
9393
bool opal_mem_hooks;
94-
char **tls;
95-
char **devices;
94+
char *tls;
95+
char *devices;
9696
} opal_common_ucx_module_t;
9797

9898
typedef struct opal_common_ucx_del_proc {

opal/mca/patcher/base/patcher_base_frame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int opal_patcher_base_close(void)
9090
return opal_patcher->patch_fini();
9191
}
9292

93-
return OPAL_SUCCESS;
93+
return mca_base_framework_components_close(&opal_patcher_base_framework, NULL);
9494
}
9595

9696
/* Use default register/open functions */

0 commit comments

Comments
 (0)