Skip to content

Commit

Permalink
UCS/TEST: Remove entry from configuration list when library is unloaded
Browse files Browse the repository at this point in the history
 When UCT is loaded, the static initializer adds it's configuration
tables to the global list in UCS. When UCT is unloaded, need to remove
them from that list, otherwise the list will point to invalid memory.
  • Loading branch information
yosefe committed Jun 2, 2019
1 parent 7e67a4b commit 0a5b668
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
10 changes: 10 additions & 0 deletions contrib/test_jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,15 @@ test_dlopen() {
! grep '^socket' strace.log
}

test_dlopen_cfg_print() {
../contrib/configure-devel --prefix=$ucx_inst
$MAKE clean
$MAKE

echo "==== Running test_dlopen_cfg_print ===="
./test/apps/test_dlopen_cfg_print
}

test_memtrack() {
../contrib/configure-devel --prefix=$ucx_inst
$MAKE clean
Expand Down Expand Up @@ -930,6 +939,7 @@ run_tests() {
do_distributed_task 1 4 run_ucp_client_server
do_distributed_task 3 4 test_profiling
do_distributed_task 3 4 test_dlopen
do_distributed_task 2 4 test_dlopen_cfg_print
do_distributed_task 3 4 test_memtrack
do_distributed_task 0 4 test_unused_env_var
do_distributed_task 1 3 test_malloc_hook
Expand Down
17 changes: 11 additions & 6 deletions src/ucs/config/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,19 @@ typedef struct ucs_config_global_list_entry {


#define UCS_CONFIG_REGISTER_TABLE(_fields, _name, _prefix, _type) \
static ucs_config_global_list_entry_t _fields##_config_entry; \
UCS_STATIC_INIT { \
ucs_config_global_list_entry_t *entry = &_fields##_config_entry; \
extern ucs_list_link_t ucs_config_global_list; \
static ucs_config_global_list_entry_t entry; \
entry.fields = _fields; \
entry.name = _name; \
entry.prefix = _prefix; \
entry.size = sizeof(_type); \
ucs_list_add_tail(&ucs_config_global_list, &entry.list); \
entry->fields = _fields; \
entry->name = _name; \
entry->prefix = _prefix; \
entry->size = sizeof(_type); \
ucs_list_add_tail(&ucs_config_global_list, &entry->list); \
} \
\
UCS_STATIC_CLEANUP { \
ucs_list_del(&_fields##_config_entry.list); \
}


Expand Down
11 changes: 9 additions & 2 deletions test/apps/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ SUBDIRS = sockaddr
endif

noinst_PROGRAMS = \
test_dlopen

test_dlopen \
test_dlopen_cfg_print

objdir = $(shell sed -n -e 's/^objdir=\(.*\)$$/\1/p' $(LIBTOOL))

Expand All @@ -21,6 +21,13 @@ test_dlopen_CPPFLAGS = $(BASE_CPPFLAGS) -g -DUCP_LIB_PATH=$(abs_top_builddir)/sr
test_dlopen_CFLAGS = $(BASE_CFLAGS)
test_dlopen_LDADD = -ldl

test_dlopen_cfg_print_SOURCES = test_dlopen_cfg_print.c
test_dlopen_cfg_print_CPPFLAGS = $(BASE_CPPFLAGS) -g \
-DUCS_LIB_PATH=$(abs_top_builddir)/src/ucs/$(objdir)/libucs.so \
-DUCT_LIB_PATH=$(abs_top_builddir)/src/uct/$(objdir)/libuct.so
test_dlopen_cfg_print_CFLAGS = $(BASE_CFLAGS)
test_dlopen_cfg_print_LDADD = -ldl

if HAVE_TCMALLOC
noinst_PROGRAMS += test_tcmalloc
test_tcmalloc_SOURCES = test_tcmalloc.c
Expand Down

0 comments on commit 0a5b668

Please sign in to comment.