Hi, I am using valgrind to check memory leak for my program. Valgrind leak reported in libnvf.so.
==1552028== Memcheck, a memory error detector
==1552028== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1552028== Using Valgrind-3.18.0.GIT-4c8c4a9c3a-20210409 and LibVEX; rerun with -h for copyright info
==1552028== Command: ././bin/my_program
==1552028== Parent PID: 1552025
==1552028==
--1552028--
--1552028-- Valgrind options:
--1552028-- --verbose
--1552028-- --log-file=./tools/valgrind/my_program.valgrind
--1552028-- --show-leak-kinds=all
--1552028-- --leak-check=full
--1552028-- --track-origins=yes
--1552028-- Contents of /proc/version:
--1552028-- Linux version 5.4.0-77-generic (buildd@lgw01-amd64-028) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021
--1552028--
--1552028-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-ssse3-avx-avx2-bmi-f16c-rdrand-rdseed
--1552028-- Page sizes: currently 4096, max supported 4096
--1552028-- Valgrind library directory: /opt/valgrind/3.18.0.GIT/libexec/valgrind
--1552028-- Reading syms from /prj/bin/my_program
--1552028-- Reading syms from /lib/x86_64-linux-gnu/ld-2.31.so
--1552028-- Considering /lib/x86_64-linux-gnu/ld-2.31.so ..
--1552028-- .. CRC mismatch (computed b1e31cec wanted 7bd1f8ba)
--1552028-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.31.so ..
--1552028-- .. CRC is valid
--1552028-- Reading syms from /opt/valgrind/3.18.0.GIT/libexec/valgrind/memcheck-amd64-linux
--1552028-- object doesn't have a dynamic symbol table
--1552028-- Scheduler: using generic scheduler lock implementation.
--1552028-- Reading suppressions file: /opt/valgrind/3.18.0.GIT/libexec/valgrind/default.supp
==1552028== embedded gdbserver: reading from tmp/vgdb-pipe-from-vgdb-to-1552028-by-alig-on-???
==1552028== embedded gdbserver: writing to tmp/vgdb-pipe-to-vgdb-from-1552028-by-alig-on-???
==1552028== embedded gdbserver: shared mem tmp/vgdb-pipe-shared-mem-vgdb-1552028-by-alig-on-???
==1552028==
==1552028== TO CONTROL THIS PROCESS USING vgdb (which you probably
==1552028== don't want to do, unless you know exactly what you're doing,
==1552028== or are doing some strange experiment):
==1552028== /opt/valgrind/3.18.0.GIT/libexec/valgrind/../../bin/vgdb --pid=1552028 ...command...
==1552028==
==1552028== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==1552028== /path/to/gdb ././bin/my_program
==1552028== and then give GDB the following command
==1552028== target remote | /opt/valgrind/3.18.0.GIT/libexec/valgrind/../../bin/vgdb --pid=1552028
==1552028== --pid is optional if only one valgrind process is running
==1552028==
--1552028-- REDIR: 0x4022f60 (ld-linux-x86-64.so.2:strlen) redirected to 0x580b2e82 (vgPlain_amd64_linux_REDIR_FOR_strlen)
--1552028-- REDIR: 0x4022d30 (ld-linux-x86-64.so.2:index) redirected to 0x580b2e9c (vgPlain_amd64_linux_REDIR_FOR_index)
--1552028-- Reading syms from /opt/valgrind/3.18.0.GIT/libexec/valgrind/vgpreload_core-amd64-linux.so
--1552028-- Reading syms from /opt/valgrind/3.18.0.GIT/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
==1552028== WARNING: new redirection conflicts with existing -- ignoring it
--1552028-- old: 0x04022f60 (strlen ) R-> (0000.0) 0x580b2e82 vgPlain_amd64_linux_REDIR_FOR_strlen
--1552028-- new: 0x04022f60 (strlen ) R-> (2007.0) 0x04844390 strlen
--1552028-- REDIR: 0x401f740 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4845260 (strcmp)
--1552028-- REDIR: 0x40234c0 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4848df0 (mempcpy)
--1552028-- Reading syms from /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libblas_lp64.so.0
--1552028-- Reading syms from /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_intel_ilp64.so.1
--1552028-- Reading syms from /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_sequential.so.1
--1552028-- Reading syms from /opt/intel/oneapi/mkl/2021.3.0/lib/intel64/libmkl_core.so.1
--1552028-- Reading syms from /lib/x86_64-linux-gnu/libpthread-2.31.so
--1552028-- Considering /usr/lib/debug/.build-id/ee/b5b055a9d738db64e450065f88980bebfc9cc2.debug ..
--1552028-- .. build-id is valid
--1552028-- Reading syms from /lib/x86_64-linux-gnu/libm-2.31.so
--1552028-- Considering /lib/x86_64-linux-gnu/libm-2.31.so ..
--1552028-- .. CRC mismatch (computed 5f7b2a42 wanted ffb185de)
--1552028-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libm-2.31.so ..
--1552028-- .. CRC is valid
--1552028-- Reading syms from /lib/x86_64-linux-gnu/libdl-2.31.so
--1552028-- Considering /lib/x86_64-linux-gnu/libdl-2.31.so ..
--1552028-- .. CRC mismatch (computed 3ec850eb wanted 9bcd6f8f)
--1552028-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.31.so ..
--1552028-- .. CRC is valid
--1552028-- Reading syms from /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so
--1552028-- Reading syms from /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvomp.so
--1552028-- Reading syms from /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvcpumath.so
--1552028-- Reading syms from /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvc.so
--1552028-- Reading syms from /lib/x86_64-linux-gnu/librt-2.31.so
--1552028-- Considering /lib/x86_64-linux-gnu/librt-2.31.so ..
--1552028-- .. CRC mismatch (computed cbb60aeb wanted a2f7da19)
--1552028-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/librt-2.31.so ..
--1552028-- .. CRC is valid
--1552028-- Reading syms from /lib/x86_64-linux-gnu/libc-2.31.so
--1552028-- Considering /lib/x86_64-linux-gnu/libc-2.31.so ..
--1552028-- .. CRC mismatch (computed 11759501 wanted 88150686)
--1552028-- Considering /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.31.so ..
--1552028-- .. CRC is valid
--1552028-- Reading syms from /opt/gcc/11.1.0/lib64/libgcc_s.so.1
--1552028-- REDIR: 0x4023320 (ld-linux-x86-64.so.2:stpcpy) redirected to 0x4847ad0 (stpcpy)
--1552028-- Reading syms from /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libacchost.so
--1552028-- REDIR: 0xe87f600 (libc.so.6:memmove) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
==1552028== Preferring higher priority redirection:
--1552028-- old: 0x0e96a670 (__memcpy_avx_unalign) R-> (2018.0) 0x04846530 __memcpy_avx_unaligned_erms
--1552028-- new: 0x0e96a670 (__memcpy_avx_unalign) R-> (2018.1) 0x04847e50 memmove
--1552028-- REDIR: 0xe87e900 (libc.so.6:strncpy) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f930 (libc.so.6:strcasecmp) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e220 (libc.so.6:strcat) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e960 (libc.so.6:rindex) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe880dd0 (libc.so.6:rawmemchr) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe89be60 (libc.so.6:wmemchr) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe89b9a0 (libc.so.6:wcscmp) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f760 (libc.so.6:mempcpy) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f590 (libc.so.6:bcmp) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e890 (libc.so.6:strncmp) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e2d0 (libc.so.6:strcmp) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f6c0 (libc.so.6:memset) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe89b960 (libc.so.6:wcschr) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e7f0 (libc.so.6:strnlen) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e3b0 (libc.so.6:strcspn) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f980 (libc.so.6:strncasecmp) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e350 (libc.so.6:strcpy) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87fad0 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe89d0d0 (libc.so.6:wcsnlen) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe89b9e0 (libc.so.6:wcscpy) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e9a0 (libc.so.6:strpbrk) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e280 (libc.so.6:index) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87e7b0 (libc.so.6:strlen) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe887d20 (libc.so.6:memrchr) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f9d0 (libc.so.6:strcasecmp_l) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f550 (libc.so.6:memchr) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe89bab0 (libc.so.6:wcslen) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87ec60 (libc.so.6:strspn) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f8d0 (libc.so.6:stpncpy) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87f870 (libc.so.6:stpcpy) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe880e10 (libc.so.6:strchrnul) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe87fa20 (libc.so.6:strncasecmp_l) redirected to 0x48331a2 (_vgnU_ifunc_wrapper)
--1552028-- REDIR: 0xe967490 (libc.so.6:__strrchr_avx2) redirected to 0x4843dd0 (rindex)
--1552028-- REDIR: 0xe967660 (libc.so.6:__strlen_avx2) redirected to 0x4844270 (strlen)
--1552028-- REDIR: 0xe96a670 (libc.so.6:__memcpy_avx_unaligned_erms) redirected to 0x4847e50 (memmove)
--1552028-- REDIR: 0xe96aaf0 (libc.so.6:__memset_avx2_unaligned_erms) redirected to 0x4847d50 (memset)
--1552028-- REDIR: 0xe968ba0 (libc.so.6:__strcpy_avx2) redirected to 0x48443c0 (strcpy)
--1552028-- REDIR: 0xe962fa0 (libc.so.6:__strncmp_avx2) redirected to 0x4844940 (strncmp)
--1552028-- REDIR: 0xe968f30 (libc.so.6:__strncpy_avx2) redirected to 0x4844540 (strncpy)
--1552028-- REDIR: 0xe9672a0 (libc.so.6:__strchrnul_avx2) redirected to 0x48488e0 (strchrnul)
--1552028-- REDIR: 0xe879260 (libc.so.6:malloc) redirected to 0x483e729 (malloc)
--1552028-- REDIR: 0xe879850 (libc.so.6:free) redirected to 0x4840ede (free)
--1552028-- REDIR: 0xe962b60 (libc.so.6:__strcmp_avx2) redirected to 0x4845160 (strcmp)
--1552028-- REDIR: 0xe87f120 (libc.so.6:__GI_strstr) redirected to 0x4849090 (__strstr_sse2)
--1552028-- REDIR: 0xe963c50 (libc.so.6:__memcmp_avx2_movbe) redirected to 0x48475f0 (bcmp)
--1552028-- REDIR: 0xe87ac90 (libc.so.6:calloc) redirected to 0x4843162 (calloc)
--1552028-- REDIR: 0xe96a650 (libc.so.6:__mempcpy_avx_unaligned_erms) redirected to 0x48489f0 (mempcpy)
--1552028-- REDIR: 0xe87a000 (libc.so.6:realloc) redirected to 0x48433a7 (realloc)
==1552028==
==1552028== HEAP SUMMARY:
==1552028== in use at exit: 80,763,016 bytes in 102,066 blocks
==1552028== total heap usage: 19,094,220 allocs, 18,992,154 frees, 258,981,830,859 bytes allocated
==1552028==
==1552028== Searching for pointers to 102,066 not-freed blocks
==1552028== Checked 14,468,256 bytes
==1552028==
==1552028== 464 bytes in 1 blocks are still reachable in loss record 1 of 9
==1552028== at 0x484342B: realloc (vg_replace_malloc.c:1192)
==1552028== by 0xCFEB6B2: fw_check_size (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x107: ???
==1552028== by 0x107: ???
==1552028== by 0xFF: ???
==1552028== by 0xCFE8749: fw_write (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028==
==1552028== 2,008 bytes in 1 blocks are still reachable in loss record 2 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xCFE58FE: fr_init (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028==
==1552028== 12,288 bytes in 1 blocks are still reachable in loss record 3 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA240: __fort_malloc (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x403892: main (in /prj/bin/my_program)
==1552028==
==1552028== 37,488 bytes in 790 blocks are possibly lost in loss record 4 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA3C0: __fort_gmalloc_without_abort (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x26: ???
==1552028== by 0x18: ???
==1552028==
==1552028== 85,952 bytes in 122 blocks are possibly lost in loss record 5 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA3C0: __fort_gmalloc_without_abort (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x26: ???
==1552028== by 0xD: ???
==1552028==
==1552028== 1,710,576 bytes in 580 blocks are possibly lost in loss record 6 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA3C0: __fort_gmalloc_without_abort (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x26: ???
==1552028== by 0x1B: ???
==1552028==
==1552028== 2,105,456 bytes in 45,305 blocks are definitely lost in loss record 7 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA3C0: __fort_gmalloc_without_abort (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x26: ???
==1552028== by 0x18: ???
==1552028==
==1552028== 4,394,512 bytes in 6,855 blocks are definitely lost in loss record 8 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA3C0: __fort_gmalloc_without_abort (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x26: ???
==1552028== by 0xD: ???
==1552028==
==1552028== 72,414,272 bytes in 48,411 blocks are definitely lost in loss record 9 of 9
==1552028== at 0x483E79B: malloc (vg_replace_malloc.c:380)
==1552028== by 0xD0CA3C0: __fort_gmalloc_without_abort (in /opt/nvidia/hpc_sdk/Linux_x86_64/21.5/compilers/lib/libnvf.so)
==1552028== by 0x26: ???
==1552028== by 0x1B: ???
==1552028==
==1552028== LEAK SUMMARY:
==1552028== definitely lost: 78,914,240 bytes in 100,571 blocks
==1552028== indirectly lost: 0 bytes in 0 blocks
==1552028== possibly lost: 1,834,016 bytes in 1,492 blocks
==1552028== still reachable: 14,760 bytes in 3 blocks
==1552028== suppressed: 0 bytes in 0 blocks
==1552028==
==1552028== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)