[MINC-users] Memory Leak when using miopen_volume

Vladimir S. FONOV vladimir.fonov at gmail.com
Mon Feb 4 11:04:02 EST 2013


Hello,

I think I fixed this memory leak in the experimental development
version of libminc ( https://github.com/BIC-MNI/libminc/tree/minc_lite
- note the branch name)

On Mon, Feb 4, 2013 at 10:56 AM, Thomas Funck
<thomas.funck at mail.mcgill.ca> wrote:
> Hi,
>
> I'm getting all sorts of crazy errors (e.g. malloc returning true when it hasn't actually allocated any memory) when trying to run a program I wrote using the minc2 library. I suspect that the errors may be due to memory leaks which I encounter when using miopen_volume and then close the volume with miclose_volume. Running valgrind, I get the following errors. I'm compiling and running my code on the bic server. Is this normal or have I made a mistake in my code?
>
> Many thanks for any help!
>
> Best,
>
> Thomas
>
> ==32603== Memcheck, a memory error detector
> ==32603== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
> ==32603== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
> ==32603== Command: ./pet -nosmooth -lp 0.15 test.mnc test_brainmask.mnc test_brainmask.mnc 30
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41A349: miopen_volume (volume.c:885)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41A34B: miopen_volume (volume.c:885)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41A7C5: miopen_volume (volume.c:888)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41A7C7: miopen_volume (volume.c:888)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41AB7E: miopen_volume (volume.c:891)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41AB80: miopen_volume (volume.c:891)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> ==32603== Conditional jump or move depends on uninitialised value(s)
> ==32603==    at 0x41ABE5: miopen_volume (volume.c:894)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==  Uninitialised value was created by a stack allocation
> ==32603==    at 0x41A27D: miopen_volume (volume.c:1047)
> ==32603==
> File test.mnc has dimensions 9 47 128 128.
> Average separations: t=1.000000, z=-3.125000 y=2.202420 x=2.202420
> Starts: 0.000000 -348.909988 -139.853657 -139.853657
> ==32603==
> ==32603== HEAP SUMMARY:
> ==32603==     in use at exit: 1,067 bytes in 28 blocks
> ==32603==   total heap usage: 3,999 allocs, 3,971 frees, 1,075,894 bytes allocated
> ==32603==
> ==32603== 128 bytes in 4 blocks are definitely lost in loss record 3 of 7
> ==32603==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
> ==32603==    by 0x416A4B: alloc2d (m2util.c:1709)
> ==32603==    by 0x416FFE: miinvert_transform (m2util.c:1925)
> ==32603==    by 0x41A975: miopen_volume (volume.c:1142)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==
> ==32603== 128 bytes in 4 blocks are definitely lost in loss record 4 of 7
> ==32603==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
> ==32603==    by 0x416A4B: alloc2d (m2util.c:1709)
> ==32603==    by 0x417010: miinvert_transform (m2util.c:1926)
> ==32603==    by 0x41A975: miopen_volume (volume.c:1142)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==
> ==32603== 128 bytes in 4 blocks are definitely lost in loss record 5 of 7
> ==32603==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
> ==32603==    by 0x416A4B: alloc2d (m2util.c:1709)
> ==32603==    by 0x416ED9: scaled_maximal_pivoting_gaussian_elimination_real (m2util.c:1885)
> ==32603==    by 0x41707F: miinvert_transform (m2util.c:1937)
> ==32603==    by 0x41A975: miopen_volume (volume.c:1142)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==
> ==32603== 128 bytes in 4 blocks are definitely lost in loss record 6 of 7
> ==32603==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
> ==32603==    by 0x416A4B: alloc2d (m2util.c:1709)
> ==32603==    by 0x416EE5: scaled_maximal_pivoting_gaussian_elimination_real (m2util.c:1886)
> ==32603==    by 0x41707F: miinvert_transform (m2util.c:1937)
> ==32603==    by 0x41A975: miopen_volume (volume.c:1142)
> ==32603==    by 0x40463D: getdimensions (pet_input.c:183)
> ==32603==    by 0x4057F1: processImage (pet_core.c:50)
> ==32603==    by 0x4062E6: main (pet_core.c:388)
> ==32603==
> ==32603== LEAK SUMMARY:
> ==32603==    definitely lost: 512 bytes in 16 blocks
> ==32603==    indirectly lost: 0 bytes in 0 blocks
> ==32603==      possibly lost: 0 bytes in 0 blocks
> ==32603==    still reachable: 555 bytes in 12 blocks
> ==32603==         suppressed: 0 bytes in 0 blocks
> ==32603== Reachable blocks (those to which a pointer was found) are not shown.
> ==32603== To see them, rerun with: --leak-check=full --show-reachable=yes
> ==32603==
> ==32603== For counts of detected and suppressed errors, rerun with: -v
> ==32603== ERROR SUMMARY: 11 errors from 11 contexts (suppressed: 4 from 4)
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users



-- 
Best regards,

 Vladimir S. Fonov ~ vladimir <dot> fonov <at> gmail <dot> com


More information about the MINC-users mailing list