usnistgov / frvt

Repository for the Face Recognition Vendor Test (FRVT)
Other
258 stars 113 forks source link

valgrind is detecting memory leaks in python code #98

Open AwaisPF opened 1 year ago

AwaisPF commented 1 year ago

Even i ran simple cpp file with valgrind having belllow code

#include "Python.h"
#include "iostream"

using namespace std;

int main(){
    setenv("PYTHONPATH",".",1);
    Py_Initialize();
    cout <<"Hello\n";
    Py_Finalize();

}

got bellow errors on valgring.

==140416==    by 0x49F424B: Py_InitializeEx (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x1091ED: main (in /additional_drive/nist/frvt_onnx_sequential/11/test_mem)
==140416==  Address 0x5387020 is 1,520 bytes inside a block of size 2,208 free'd
==140416==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==140416==    by 0x4ACD397: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4AC9E1F: PyDict_SetDefault (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4A62DFF: PyUnicode_InternInPlace (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4A62E90: PyUnicode_InternFromString (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4AFC4C1: PyDescr_NewMethod (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x48E34AA: PyType_Ready (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4AB8E04: _PyTypes_Init (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x49F3A6A: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x49F41A2: Py_InitializeFromConfig (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x49F424B: Py_InitializeEx (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x1091ED: main (in /additional_drive/nist/frvt_onnx_sequential/11/test_mem)
==140416==  Block was alloc'd at
...
...
...
==140416==  Block was alloc'd at
==140416==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==140416==    by 0x4AB69E7: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4B20CB7: PyGrammar_AddAccelerators (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4B23184: PyParser_New (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4B26DD2: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x49E79DA: PyParser_ASTFromStringObject (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x49E8387: PyRun_StringFlags (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4A2BADF: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x4ABB546: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x48D0D6C: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x48D246C: _PyEval_EvalFrameDefault (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416==    by 0x48DC06A: ??? (in /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0)
==140416== 
==140416== ERROR SUMMARY: 898 errors from 107 contexts (suppressed: 0 from 0)

but without vargind there are no errors please suggest me do I need to resolve these errors as nist suggest and replied that I have to fix memory leakage issue BTW I am applieng for NIST_11 challenge every thing is working fine but memory leakage is the problem and I have on google and found out that python by default does that and it own garbage collector frees memory and may that is why valgrind unable to detect that.

AwaisPF commented 1 year ago

@mlngan can you please help me to solve this issue