Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks in BP5Deserializer::InstallMetaData #3608

Closed
dqwu opened this issue May 10, 2023 · 5 comments
Closed

Memory leaks in BP5Deserializer::InstallMetaData #3608

dqwu opened this issue May 10, 2023 · 5 comments

Comments

@dqwu
Copy link

dqwu commented May 10, 2023

This issue is reproducible with latest ADIOS2 2.9.0 and a simple C example of SCORPIO.

Steps to reproduce on a Linux workstation with GCC compiler and its LeakSanitizer:

git clone https://github.com/E3SM-Project/scorpio.git
cd scorpio

mkdir build
cd build

CFLAGS="-fsanitize=leak -fno-omit-frame-pointer -g" \
ADIOS2_DIR=/path/to/adios2/installation \
CC=mpicc CXX=mpicxx FC=mpifort cmake -Wno-dev \
-DWITH_ADIOS2=ON \
-DADIOS_BP2NC_TEST=ON \
-DWITH_NETCDF=OFF \
-DPnetCDF_PATH=/path/to/pnetcdf/installation \
-DPIO_USE_MALLOC=ON \
-DPIO_ENABLE_EXAMPLES=ON \
..

make

cd examples/c
mpiexec -n 2 ./example1

Example output on a Linux workstation of ANL:

=================================================================
==2414827==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 3 object(s) allocated from:
    #0 0x7f80f14a7ac4 in operator new(unsigned long) /nfs/gce/software/tmp/svcbuilder/spack-stage-gcc-11.1.0-qsjmpcgt7go2ourefdh2i5z2g5u7bxmk/spack-src/libsanitizer/lsan/lsan_interceptors.cpp:238
    #1 0x864501 in adios2::format::BP5Deserializer::InstallMetaData(void*, unsigned long, unsigned long, unsigned long) ADIOS2-2.9.0/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp:717
    #2 0x83825e in adios2::core::engine::BP5Reader::InstallMetadataForTimestep(unsigned long) ADIOS2-2.9.0/source/adios2/engine/bp5/BP5Reader.cpp:81

Valgrind also reports similar memory leaks:

==2420468== 40 (24 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 5 of 10
==2420468==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==2420468==    by 0x864501: adios2::format::BP5Deserializer::InstallMetaData(void*, unsigned long, unsigned long, unsigned long) (in scorpio/build/examples/c/example1)
==2420468==    by 0x83825E: adios2::core::engine::BP5Reader::InstallMetadataForTimestep(unsigned long) (in scorpio/build/examples/c/example1)
==2420468==    by 0x83C265: adios2::core::engine::BP5Reader::BeginStep(adios2::StepMode, float) (in scorpio/build/examples/c/example1)
==2420468==    by 0xA055FC: ConvertBPFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (in scorpio/build/examples/c/example1)
==2420468==    by 0xA073B1: ConvertBPToNC(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (in scorpio/build/examples/c/example1)
==2420468==    by 0xA07DBD: C_API_ConvertBPToNC (in scorpio/build/examples/c/example1)
==2420468==    by 0x45D598: PIOc_closefile (in scorpio/build/examples/c/example1)
==2420468==    by 0x45B579: main (in scorpio/build/examples/c/example1)

Additional information:

  • Reproducible with ADIOS2 2.9.0 (released on Mar 30 2023) and latest master branch
  • Not reproducible with ADIOS2 built with master branch on Nov 30 2022
  • A similar issue has been fixed for ADIOS2 2.9.0, see Memory Leak in BP5Deserializer #3443
@dqwu
Copy link
Author

dqwu commented May 10, 2023

@eisenhauer
Could you please take a look? Thanks.

@eisenhauer
Copy link
Member

On it...

@dqwu
Copy link
Author

dqwu commented May 10, 2023

@eisenhauer
FYI, the same memory leaks issue is also mentioned in #3580

@eisenhauer
Copy link
Member

Found the issue and will have a PR in momentarily...

@vicentebolea
Copy link
Collaborator

This was resolved at #3619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants