lammps / lammps

Public development project of the LAMMPS MD software package
https://www.lammps.org
GNU General Public License v2.0
2.24k stars 1.72k forks source link

Possible memory leak in USER-MGPT package #578

Closed akohlmey closed 3 years ago

akohlmey commented 7 years ago

Summary

There seems to be a memory leak in the USER-MGPT package

Type of Issue

Bug report

Detailed Description (Enhancement Suggestion)

When running the example inputs for pair style mgpt with an executable compiled with GCC using the -fsanitize=address flag, the following report of a memory leak is produced.

=================================================================
==6292==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 88392 byte(s) in 1 object(s) allocated from:
    #0 0x7ff24023d040 in operator new[](unsigned long) (/lib64/libasan.so.3+0xc8040)
    #1 0x26fe20f in potdata::readpot(char const*, char const*, double) ../mgpt_readpot.cpp:351
    #2 0x61c00000fe27  (<unknown module>)

Direct leak of 12160 byte(s) in 1 object(s) allocated from:
    #0 0x7ff24023d040 in operator new[](unsigned long) (/lib64/libasan.so.3+0xc8040)
    #1 0x26fd826 in potdata::readpot(char const*, char const*, double) ../mgpt_readpot.cpp:517
    #2 0x61c00000fe27  (<unknown module>)

Direct leak of 12160 byte(s) in 1 object(s) allocated from:
    #0 0x7ff24023d040 in operator new[](unsigned long) (/lib64/libasan.so.3+0xc8040)
    #1 0x26fd88c in potdata::readpot(char const*, char const*, double) ../mgpt_readpot.cpp:518
    #2 0x61c00000fe27  (<unknown module>)

Direct leak of 116 byte(s) in 1 object(s) allocated from:
    #0 0x7ff24023d040 in operator new[](unsigned long) (/lib64/libasan.so.3+0xc8040)
    #1 0x26fc138 in potdata::readpot(char const*, char const*, double) ../mgpt_readpot.cpp:239
    #2 0x61c00000fe27  (<unknown module>)

SUMMARY: AddressSanitizer: 112828 byte(s) leaked in 4 allocation(s).

This looks like potential parameter data is not freed when the pair style is deleted. This is not a big issue for normal inputs with a single, but may become a problem for people running many short computations with different settings via loops or the library interface.

LAMMPS Version (Bug Report)

6 July 2017

Expected Behavior (Bug Report)

All memory allocated by LAMMPS classes should be freed

Actual Behavior (Bug Report)

The instrumented executable reports that over 100kB are leaked each for the example inputs

Steps to Reproduce (Bug Report)

Compile LAMMPS using a recent GCC g++ compiler (tested with version 6.x) and add -fsanitize=address to the compiler and linker flags. Then run the input decks in examples/USER/mgpt

Further Information, Files, and Links

n/a

akohlmey commented 4 years ago

@sjplimp can you please verify, if the authors of this code are still maintaining their contribution to LAMMPS? This code has not seen any updates by the authors since it original integration 5 years ago. An this issue is now open for 2 1/2 years. All changes since have been to keep it consistent with the rest of LAMMPS.