Skip to content

Memory leak when using the @disable macro #419

@danielhollas

Description

@danielhollas

It looks like there is a memory leak when I used a @disable macro annotating the pFUnit test case

    @test
    @disable
    subroutine test_disabled()
       ! This test needs to be skipped
       ...
    end subroutine

Here's the output I got when compiling and running my test suite with gfortran and -fsanitize=address,leak


=================================================================
==2109==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7fd3d5e56808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x55c76536db53 in __pf_stringtestannotationmap_MOD_ti_set_capacity /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:639
make[1]: Leaving directory '/home/runner/work/ABIN/ABIN/unit_tests'
    #2 0x55c76536d9f7 in __pf_stringtestannotationmap_MOD_ti_grow_to /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:664
    #3 0x55c76536e522 in __pf_stringtestannotationmap_MOD_ti_push_back /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:401
    #4 0x55c765378b92 in __pf_stringtestannotationmap_MOD_s_insert /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/altSet_impl.inc:347
    #5 0x55c765375f03 in __pf_stringtestannotationmap_MOD_m_insert_key_value /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/map_impl.inc:84
    #6 0x55c764ebf34a in test_spline_suite_ (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x46b34a)
    #7 0x55c764eba753 in __loader_MOD_load_tests (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x466753)
    #8 0x55c7653bc2d3 in __funit_MOD_generic_run /home/runner/pfunit/src/funit/FUnit.F90:111
    #9 0x55c7653c558a in __funit_MOD_run /home/runner/pfunit/src/funit/FUnit.F90:33
    #10 0x55c7653c55eb in funit_main_ /home/runner/pfunit/src/funit/funit_main.F90:16
    #11 0x55c764ebb1bd in MAIN__ (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x4671bd)
    #12 0x55c764ebb20b in main (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x46720b)
    #13 0x7fd3d4b57082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7fd3d5e56808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x55c76536db53 in __pf_stringtestannotationmap_MOD_ti_set_capacity /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:639
    #2 0x55c76536d9f7 in __pf_stringtestannotationmap_MOD_ti_grow_to /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:664
    #3 0x55c76536e522 in __pf_stringtestannotationmap_MOD_ti_push_back /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:401
    #4 0x55c765378bd7 in __pf_stringtestannotationmap_MOD_s_insert /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/altSet_impl.inc:348
    #5 0x55c765375f03 in __pf_stringtestannotationmap_MOD_m_insert_key_value /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/map_impl.inc:84
    #6 0x55c764ebf34a in test_spline_suite_ (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x46b34a)
    #7 0x55c764eba753 in __loader_MOD_load_tests (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x466753)
    #8 0x55c7653bc2d3 in __funit_MOD_generic_run /home/runner/pfunit/src/funit/FUnit.F90:111
    #9 0x55c7653c558a in __funit_MOD_run /home/runner/pfunit/src/funit/FUnit.F90:33
    #10 0x55c7653c55eb in funit_main_ /home/runner/pfunit/src/funit/funit_main.F90:16
    #11 0x55c764ebb1bd in MAIN__ (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x4671bd)
    #12 0x55c764ebb20b in main (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x46720b)
    #13 0x7fd3d4b57082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7fd3d5e56808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x55c76536db53 in __pf_stringtestannotationmap_MOD_ti_set_capacity /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:639
    #2 0x55c76536d9f7 in __pf_stringtestannotationmap_MOD_ti_grow_to /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:664
    #3 0x55c76536e522 in __pf_stringtestannotationmap_MOD_ti_push_back /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/vector_impl.inc:401
    #4 0x55c765378b4d in __pf_stringtestannotationmap_MOD_s_insert /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/altSet_impl.inc:346
    #5 0x55c765375f03 in __pf_stringtestannotationmap_MOD_m_insert_key_value /home/runner/pfunit/build/extern/fArgParse/extern/gFTL-shared/extern/gFTL/include/templates/map_impl.inc:84
    #6 0x55c764ebf34a in test_spline_suite_ (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x46b34a)
    #7 0x55c764eba753 in __loader_MOD_load_tests (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x466753)
    #8 0x55c7653bc2d3 in __funit_MOD_generic_run /home/runner/pfunit/src/funit/FUnit.F90:111
    #9 0x55c7653c558a in __funit_MOD_run /home/runner/pfunit/src/funit/FUnit.F90:33
    #10 0x55c7653c55eb in funit_main_ /home/runner/pfunit/src/funit/funit_main.F90:16
    #11 0x55c764ebb1bd in MAIN__ (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x4671bd)
    #12 0x55c764ebb20b in main (/home/runner/work/ABIN/ABIN/unit_tests/spline+0x46720b)
    #13 0x7fd3d4b57082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)

SUMMARY: AddressSanitizer: 24 byte(s) leaked in 3 allocation(s).

The leak is probably not so serious per se, but it is annoying in practice if I want to run my test suite with the memory leak detection enabled since it produces false positives. In effect, I am not able to use the @disable macro in my CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions