LLNL / UnifyFS

UnifyFS: A file system for burst buffers
Other
106 stars 31 forks source link

Memory leaks in configurator #688

Open roblatham00 opened 3 years ago

roblatham00 commented 3 years ago

System information

Type Version/Name
Operating System Linux
OS Version Ubuntu-21.04
Architecture x86_64
UnifyFS Version -devel

Describe the problem you're observing

Merely initializing and finalizing unify causes memory sanitizers (valgrind, address sanitizer) to report memory leaks

Describe how to reproduce the problem

valgrind --leak-check=full --show-reachable=yes will uncover leaked memory as will compiling with -fsanitize=address

Include any warning or errors or releveant debugging data

This simple routine initializes and finalizes unify

#include <unifyfs/unifyfs_api.h>

int main(int argc, char **argv)
{
    const char * unify_prefix = "/unify-demo";
    char filename[256];
    unifyfs_handle fshdl = UNIFYFS_INVALID_HANDLE;

    int ret = unifyfs_initialize(unify_prefix, NULL, 0, &fshdl);

    ret = unifyfs_finalize(fshdl);

    return ret;
}

and when compiled with -fsanitized=address, I get the following leaks in the unify configurator

=================================================================
==14725==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 59 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715ff8 in unifyfs_config_process_environ /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:437

Direct leak of 32 byte(s) in 2 object(s) allocated from:
    #0 0x7f50cc7f6e17 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f50cc718138 in configurator_int_check /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:1013
    #2 0x7f50cc718138 in configurator_int_check /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:994

Direct leak of 13 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc7150bc in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc731d46 in unifyfs_initialize /home/robl/work/UnifyFS/client/src/unifyfs_api.c:53

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc72b85c in invoke_client_metaget_rpc /home/robl/work/UnifyFS/client/src/margo_client.c:494

Direct leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71501c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715161 in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 9 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715ca4 in unifyfs_config_process_environ /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:437

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71514e in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715f41 in unifyfs_config_process_environ /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:437

Direct leak of 5 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc7150cc in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71508c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71506c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715128 in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71502c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc7150dc in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71505c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc714ffc in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715187 in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715174 in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 3 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71513b in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 3 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71504c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 3 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc71509c in unifyfs_config_set_defaults /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:228

Direct leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715f7e in unifyfs_config_process_environ /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:437

Direct leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x7f50cc79d9f7 in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:454
    #1 0x7f50cc715e5c in unifyfs_config_process_environ /home/robl/work/UnifyFS/client/src/../../common/src/unifyfs_configurator.c:437

SUMMARY: AddressSanitizer: 223 byte(s) leaked in 26 allocation(s).

priority: low -- 223 bytes is a trivial amount of memory. they are more annoyances when I'm trying to find my own memory leaks

adammoody commented 3 years ago

Thanks for the report, @roblatham00 .

We just merged a PR from @rgmiller to fix a bunch of memory leaks that he also identified with valgrind: https://github.com/LLNL/UnifyFS/pull/684

Were you using a build after this PR was merged?

roblatham00 commented 3 years ago

I'm using a build from today 178dfd5b71 . I did notice commit 9058fe7 (which got me thinking you're in the mood for memory leak bug reports) but those are all server side changes.