MYSTRAN icon indicating copy to clipboard operation
MYSTRAN copied to clipboard

Memory leaks and uninitialized data reported from Valgrind

Open galbramc opened this issue 4 years ago • 2 comments

We are using mystran as part of a larger framework where we invoke mystran via a system call. To ensure we catch bugs in our code we run our framework through valgrind on a regular basis. However, because mystran does not free all allocated memory before exiting, we are getting false positives of memory leaks that cannot be suppressed. Would it be possible to free all allocated memory at the end of the main routine in mystran? Here is a list of leaks reported by valgrind, which may not be complete:

==1083443==    by 0x1A8C61: allocate_dof_tables_ (ALLOCATE_DOF_TABLES.f90:169)
==1083443==    by 0x38B0FE: link0_ (LINK0.f90:817)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1A815B: allocate_dof_tables_ (ALLOCATE_DOF_TABLES.f90:115)
==1083443==    by 0x38B0E1: link0_ (LINK0.f90:816)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x19A8FC: allocate_col_vec_ (ALLOCATE_COL_VEC.f90:89)
==1083443==    by 0x53DE45: link9_ (LINK9.f90:772)
==1083443==    by 0x10C01C: MAIN__ (MYSTRAN.f90:322)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1E5A4F: allocate_model_stuf_ (ALLOCATE_MODEL_STUF.f90:2560)
==1083443==    by 0x38F219: link1_ (LINK1.f90:146)
==1083443==    by 0x10B8C8: MAIN__ (MYSTRAN.f90:256)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1C1EDC: allocate_misc_mat_ (ALLOCATE_MISC_MAT.f90:88)
==1083443==    by 0x5235F4: link5_ (LINK5.f90:534)
==1083443==    by 0x10BA24: MAIN__ (MYSTRAN.f90:284)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1A86DF: allocate_dof_tables_ (ALLOCATE_DOF_TABLES.f90:143)
==1083443==    by 0x38B11B: link0_ (LINK0.f90:818)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1DE46A: allocate_model_stuf_ (ALLOCATE_MODEL_STUF.f90:2039)
==1083443==    by 0x387AB9: link0_ (LINK0.f90:341)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1DDE1F: allocate_model_stuf_ (ALLOCATE_MODEL_STUF.f90:2012)
==1083443==    by 0x387AB9: link0_ (LINK0.f90:341)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1A7B80: allocate_dof_tables_ (ALLOCATE_DOF_TABLES.f90:87)
==1083443==    by 0x38B0C4: link0_ (LINK0.f90:815)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1E2E7E: allocate_model_stuf_ (ALLOCATE_MODEL_STUF.f90:2369)
==1083443==    by 0x38903A: link0_ (LINK0.f90:561)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1E28C3: allocate_model_stuf_ (ALLOCATE_MODEL_STUF.f90:2344)
==1083443==    by 0x38903A: link0_ (LINK0.f90:561)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

==1083443==    by 0x1E22DE: allocate_model_stuf_ (ALLOCATE_MODEL_STUF.f90:2317)
==1083443==    by 0x38901D: link0_ (LINK0.f90:560)
==1083443==    by 0x10B31B: MAIN__ (MYSTRAN.f90:219)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

In addition, valgrind reports some use of uninitialized data:

==1083443== Conditional jump or move depends on uninitialised value(s)
==1083443==    at 0x53FB5B: link9_ (LINK9.f90:981)
==1083443==    by 0x10C01C: MAIN__ (MYSTRAN.f90:322)
==1083443==    by 0x10CF88: main (MYSTRAN.f90:70)

I'm happy to help test out updated code designed to free this memory.

galbramc avatar Sep 05 '21 14:09 galbramc

Here is a report from Intel Fortran: P9

ceanwang avatar Sep 27 '21 11:09 ceanwang

Hi Cean. That is something I can look at but I've got more pressing problems currently with getting the BUSH element to pass all of toto's test problems. As soon as I complete that I can take a look at the memory leak issue

dr-bill-c avatar Oct 05 '21 13:10 dr-bill-c