[argyllcms] valgrind memcheck on profile

To get a better overview what profile is doing, I've created a calltree 
using "valgrind --tool=callgrind". Doing that (just for the fun of it) I also 
ran profile with the memcheck tool. There were (only very few) "weak spots", 
but it may help to identify and resolve them. Especially (in my case here, 
profiling an RGB camera input device) one memory boundary violation has been 
encountered (by 11 bytes).

As it is a stand-alone tool, un-freed memory probably won't hurt, as it's 
freed with the termination of the process. But it may be still helpful for 
overall code sanity to look into the places where allocated memory has not 
been freed.

The valgrind + application output can be found below.

Guy

$ valgrind --tool=memcheck --leak-check=yes Debug/profile -v -D"the 
camera" -qm target
==30053== Memcheck, a memory error detector.
==30053== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==30053== Using LibVEX rev 1804, a library for dynamic binary translation.
==30053== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==30053== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation 
framework.
==30053== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==30053== For more details, rerun with: -v
==30053==
No of test patches = 285
Estimating white point
Approximate White point XYZ = 0.893400 0.925200 0.739200, Lab = 97.032465 
0.240581 2.064388
Creating optimised per channel curves
Initial White Point XYZ 0.893400 0.925200 0.739200, Lab 97.032465 0.240581 
2.064388
About to optimise temporary matrix
...................................
About to optimise input curves and matrix
.............................................................
About to optimise output curves and matrix
.............................
About to optimise input curves and matrix again
.
About to optimise input, matrix and output together
.......................
About to adjust a and b output curves for white point

About to create grid position input curves

Create final clut from scattered data
********************************************************************************************************************************************************************************************************************************************************************************************************************************
Doing White point fine tune:
Before fine tune, WP = XYZ 0.978209 0.999894 0.982466, Lab 96.665756 -1.453059 
5.009890
Creating fast inverse input lookups
Compensate scattered data for input curves
White point XYZ = 0.811536 0.847779 0.626274, Lab = 93.787342 -1.139917 
6.835547
Find black point
Black point XYZ = 0.021157 0.021799 0.017160, Lab = 16.404311 0.307091 
0.864433
Done A to B table creation
==30053== Syscall param write(buf) points to uninitialised byte(s)
==30053==    at 0x40007F2: (within /lib/ld-2.7.so)
==30053==    by 0x40D8254: (within /lib/tls/i686/cmov/libc-2.7.so)
==30053==    by 0x40D8505: _IO_file_xsputn (in /lib/tls/i686/cmov/libc-2.7.so)
==30053==    by 0x40CE8DE: fwrite (in /lib/tls/i686/cmov/libc-2.7.so)
==30053==    by 0x8054FD3: icmFileStd_write (iccstd.c:226)
==30053==    by 0x8064582: icmLut_write (icc.c:5941)
==30053==    by 0x8073A2B: icc_write (icc.c:10915)
==30053==    by 0x804D644: make_input_icc (profin.c:517)
==30053==    by 0x804BF26: main (profile.c:824)
==30053==  Address 0x459bf53 is 11 bytes inside a block of size 41,818 alloc'd
==30053==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==30053==    by 0x8054E2D: icmAllocStd_malloc (iccstd.c:137)
==30053==    by 0x8063B22: icmLut_write (icc.c:5811)
==30053==    by 0x8073A2B: icc_write (icc.c:10915)
==30053==    by 0x804D644: make_input_icc (profin.c:517)
==30053==    by 0x804BF26: main (profile.c:824)
==30053==
==30053== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 13 from 1)
==30053== malloc/free: in use at exit: 805,336 bytes in 7 blocks.
==30053== malloc/free: 11,689 allocs, 11,682 frees, 45,249,949 bytes 
allocated.
==30053== For counts of detected errors, rerun with: -v
==30053== searching for pointers to 7 not-freed blocks.
==30053== checked 1,011,220 bytes.
==30053==
==30053==
==30053== 38,760 bytes in 1 blocks are definitely lost in loss record 2 of 3
==30053==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
==30053==    by 0x804CC03: make_input_icc (profin.c:362)
==30053==    by 0x804BF26: main (profile.c:824)
==30053==
==30053== LEAK SUMMARY:
==30053==    definitely lost: 38,760 bytes in 1 blocks.
==30053==      possibly lost: 0 bytes in 0 blocks.
==30053==    still reachable: 766,576 bytes in 6 blocks.
==30053==         suppressed: 0 bytes in 0 blocks.
==30053== Reachable blocks (those to which a pointer was found) are not shown.
==30053== To see them, rerun with: --leak-check=full --show-reachable=yes
Profiling timer expired

-- 
Guy K. Kloss
Institute of Information and Mathematical Sciences
Te Kura Putaiao o Mohiohio me Pangarau
Room 2.63, Quad Block A Building
Massey University, Auckland, Albany
Private Bag 102 904, North Shore Mail Centre
voice: +64 9 414-0800 ext. 9585   fax: +64 9 441-8181
eMail: G.Kloss@xxxxxxxxxxxx  http://www.massey.ac.nz/~gkloss/

Other related posts: