From thomas.funck at mail.mcgill.ca Mon Feb 4 10:56:03 2013 From: thomas.funck at mail.mcgill.ca (Thomas Funck) Date: Mon, 4 Feb 2013 15:56:03 +0000 Subject: [MINC-users] Memory Leak when using miopen_volume Message-ID: <53F3FD0032C9CC4BA836E8F0FC2890650D6084@EXMBX2010-4.campus.MCGILL.CA> 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) From vladimir.fonov at gmail.com Mon Feb 4 11:04:02 2013 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Mon, 4 Feb 2013 11:04:02 -0500 Subject: [MINC-users] Memory Leak when using miopen_volume In-Reply-To: <53F3FD0032C9CC4BA836E8F0FC2890650D6084@EXMBX2010-4.campus.MCGILL.CA> References: <53F3FD0032C9CC4BA836E8F0FC2890650D6084@EXMBX2010-4.campus.MCGILL.CA> Message-ID: 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 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 fonov gmail com From thomas.funck at mail.mcgill.ca Mon Feb 4 12:46:16 2013 From: thomas.funck at mail.mcgill.ca (Thomas Funck) Date: Mon, 4 Feb 2013 17:46:16 +0000 Subject: [MINC-users] MINC-users Digest, Vol 91, Issue 2 In-Reply-To: References: Message-ID: <53F3FD0032C9CC4BA836E8F0FC2890650D62D4@EXMBX2010-4.campus.MCGILL.CA> Hi again, Second question of the day. I want to read in the frame lengths from a minc file and I've been trying to use "miget_attr_values" but without much success. I can get it to work with attributes that fall under the "variables:" category (e.g., study:start_hour), but not with "time" in "data:". Am I using the wrong function or the wrong path? Thanks again for the help. Thomas ________________________________________ From: minc-users-bounces at bic.mni.mcgill.ca [minc-users-bounces at bic.mni.mcgill.ca] on behalf of minc-users-request at bic.mni.mcgill.ca [minc-users-request at bic.mni.mcgill.ca] Sent: Monday, February 04, 2013 12:00 PM To: minc-users at bic.mni.mcgill.ca Subject: MINC-users Digest, Vol 91, Issue 2 Send MINC-users mailing list submissions to minc-users at bic.mni.mcgill.ca To subscribe or unsubscribe via the World Wide Web, visit http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users or, via email, send a message with subject or body 'help' to minc-users-request at bic.mni.mcgill.ca You can reach the person managing the list at minc-users-owner at bic.mni.mcgill.ca When replying, please edit your Subject line so it is more specific than "Re: Contents of MINC-users digest..." Today's Topics: 1. Memory Leak when using miopen_volume (Thomas Funck) 2. Re: Memory Leak when using miopen_volume (Vladimir S. FONOV) ---------------------------------------------------------------------- Message: 1 Date: Mon, 4 Feb 2013 15:56:03 +0000 From: Thomas Funck To: "minc-users at bic.mni.mcgill.ca" Subject: [MINC-users] Memory Leak when using miopen_volume Message-ID: <53F3FD0032C9CC4BA836E8F0FC2890650D6084 at EXMBX2010-4.campus.MCGILL.CA> Content-Type: text/plain; charset="us-ascii" 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) ------------------------------ Message: 2 Date: Mon, 4 Feb 2013 11:04:02 -0500 From: "Vladimir S. FONOV" To: MINC users mailing list Subject: Re: [MINC-users] Memory Leak when using miopen_volume Message-ID: Content-Type: text/plain; charset=ISO-8859-1 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 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 fonov gmail com ------------------------------ _______________________________________________ MINC-users mailing list MINC-users at bic.mni.mcgill.ca http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users End of MINC-users Digest, Vol 91, Issue 2 ***************************************** From vladimir.fonov at gmail.com Mon Feb 4 15:23:06 2013 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Mon, 04 Feb 2013 15:23:06 -0500 Subject: [MINC-users] MINC-users Digest, Vol 91, Issue 2 In-Reply-To: <53F3FD0032C9CC4BA836E8F0FC2890650D62D4@EXMBX2010-4.campus.MCGILL.CA> References: <53F3FD0032C9CC4BA836E8F0FC2890650D62D4@EXMBX2010-4.campus.MCGILL.CA> Message-ID: <511018AA.7030102@gmail.com> Hello, are you talking about getting information about the size of the time dimension ? On 13-02-04 12:46 PM, Thomas Funck wrote: > Second question of the day. I want to read in the frame lengths from a minc file and I've been trying to use "miget_attr_values" but without much success. I can get it to work with attributes that fall under the "variables:" category (e.g., study:start_hour), but not with "time" in "data:". Am I using the wrong function or the wrong path? Thanks again for the help. -- Best regards, Vladimir S. FONOV ~ vladimir.fonov gmail.com From jon.pipitone at utoronto.ca Thu Feb 14 14:18:19 2013 From: jon.pipitone at utoronto.ca (jon pipitone) Date: Thu, 14 Feb 2013 14:18:19 -0500 Subject: [MINC-users] Adding to minc history Message-ID: Hi all, I'd like to be able to add entries to the history attribute of a minc file so that I can record provenance when I process files with the various scripts I've written up. I know many of the minc tools do this automatically, but I also want my shell and python scripts to do this as well. Is there an already baked tool for this? I imagine it would be easy to roll something on my own by modifying the HDF headers, but I'd rather use something that has had some field testing. Thanks! Jon. From vladimir.fonov at gmail.com Thu Feb 14 14:21:18 2013 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Thu, 14 Feb 2013 14:21:18 -0500 Subject: [MINC-users] Adding to minc history In-Reply-To: References: Message-ID: Hello, I suppose you can use combination of mincinfo -attvalue :history and minc_modify_header -sappend :history="..." or minc_modify_header -sinsert :history="..." On Thu, Feb 14, 2013 at 2:18 PM, jon pipitone wrote: > Hi all, > > I'd like to be able to add entries to the history attribute of a minc file > so that I can record provenance when I process files with the various > scripts I've written up. I know many of the minc tools do this > automatically, but I also want my shell and python scripts to do this as > well. > > Is there an already baked tool for this? I imagine it would be easy to > roll something on my own by modifying the HDF headers, but I'd rather use > something that has had some field testing. > > Thanks! > Jon. > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users -- Best regards, Vladimir S. Fonov ~ vladimir fonov gmail com From a.janke at gmail.com Thu Feb 14 15:00:44 2013 From: a.janke at gmail.com (Andrew Janke) Date: Fri, 15 Feb 2013 06:00:44 +1000 Subject: [MINC-users] Adding to minc history In-Reply-To: References: Message-ID: Hi Jon, > I'd like to be able to add entries to the history attribute of a minc file > so that I can record provenance when I process files with the various > scripts I've written up. I know many of the minc tools do this > automatically, but I also want my shell and python scripts to do this as > well. Good plan! I endeavour to do this with all scripts I write. Note that you sometime also need to add history to xfm files and tag files. > Is there an already baked tool for this? I imagine it would be easy to > roll something on my own by modifying the HDF headers, but I'd rather use > something that has had some field testing. There is no pre-baked tool if only because what you want to add changes from script to script. Or at least this is what I have found. In perl, the bit(s) of code I use are like this: $me = &basename($0); # get history string chomp($history = `date`); $history .= '>>>> ' . join(' ', $me, @ARGV) . "\n"; # add the history string to the output file &do_cmd('minc_modify_header', '-sappend', ":history='$history'", $outfile); sub do_cmd { print STDOUT "@_\n" if $opt{'verbose'}; if(!$opt{'fake'}){ system(@_) == 0 or die; } } --- Note that in order to get the history string you must put the first bits of code before you do any argument processing. A code example can be found here: http://packages.bic.mni.mcgill.ca/scripts/volflip a From jon.pipitone at utoronto.ca Sun Feb 17 13:35:23 2013 From: jon.pipitone at utoronto.ca (jon pipitone) Date: Sun, 17 Feb 2013 13:35:23 -0500 Subject: [MINC-users] Adding to minc history In-Reply-To: References: Message-ID: Thanks guys, this is perfect. minc_modify_header to the rescue. Jon. On Thu, Feb 14, 2013 at 3:00 PM, Andrew Janke wrote: > Hi Jon, > > > I'd like to be able to add entries to the history attribute of a minc > file > > so that I can record provenance when I process files with the various > > scripts I've written up. I know many of the minc tools do this > > automatically, but I also want my shell and python scripts to do this as > > well. > > Good plan! I endeavour to do this with all scripts I write. Note that > you sometime also need to add history to xfm files and tag files. > > > Is there an already baked tool for this? I imagine it would be easy to > > roll something on my own by modifying the HDF headers, but I'd rather use > > something that has had some field testing. > > There is no pre-baked tool if only because what you want to add > changes from script to script. Or at least this is what I have found. > In perl, the bit(s) of code I use are like this: > > > $me = &basename($0); > > # get history string > chomp($history = `date`); > $history .= '>>>> ' . join(' ', $me, @ARGV) . "\n"; > > # add the history string to the output file > &do_cmd('minc_modify_header', > '-sappend', ":history='$history'", > $outfile); > > > sub do_cmd { > print STDOUT "@_\n" if $opt{'verbose'}; > if(!$opt{'fake'}){ > system(@_) == 0 or die; > } > } > > --- > > Note that in order to get the history string you must put the first > bits of code before you do any argument processing. > > A code example can be found here: > > http://packages.bic.mni.mcgill.ca/scripts/volflip > > > a > _______________________________________________ > MINC-users at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users >