valgrind reporting: blocks still reachable with magickwand

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
toasty
Posts: 16
Joined: 2012-12-06T17:56:02-07:00
Authentication code: 6789

valgrind reporting: blocks still reachable with magickwand

Post by toasty »

I'm using LinuxMint 14.0 and I had to apt-get a few extra magickwand libraries such as: libmagickwand-dev libmagickwand5 libmagickcore5 to get it to compile. I'm compiling the logo_1.c example from here:
http://members.shaw.ca/el.supremo/MagickWand/
This is the code:

Code: Select all

#include<stdio.h>
#include<stdlib.h>
#include<wand/magick_wand.h>

void test_wand(void)
{
	MagickWand *mw = NULL;

	MagickWandGenesis();

	/* Create a wand */
	mw = NewMagickWand();

	/* Read the input image */
	MagickReadImage(mw,"logo:");
	/* write it */
	MagickWriteImage(mw,"logo.jpg");

	/* Tidy up */
	if(mw) mw = DestroyMagickWand(mw);

	MagickWandTerminus();
}

int main (int argc, char *argv[]) {
  test_wand();
  return(0);
}
This is the compile line:

Code: Select all

gcc -I/usr/include/ImageMagick -g -o logo_1 logo_1.c -lMagickWand -lMagickCore
I run it with the following valgrind line:

Code: Select all

 valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./logo_1
I'm getting:

Code: Select all

==11805== Memcheck, a memory error detector
==11805== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==11805== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==11805== Command: ./logo_1
==11805== 
==11805== 
==11805== FILE DESCRIPTORS: 3 open at exit.
==11805== Open file descriptor 2: /dev/pts/9
==11805==    <inherited from parent>
==11805== 
==11805== Open file descriptor 1: /dev/pts/9
==11805==    <inherited from parent>
==11805== 
==11805== Open file descriptor 0: /dev/pts/9
==11805==    <inherited from parent>
==11805== 
==11805== 
==11805== HEAP SUMMARY:
==11805==     in use at exit: 180 bytes in 9 blocks
==11805==   total heap usage: 1,173 allocs, 1,164 frees, 4,535,557 bytes allocated
==11805== 
==11805== 7 bytes in 1 blocks are still reachable in loss record 1 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB40FA: lt__malloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB62FF: ??? (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB6F8C: lt_dlopenadvise (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB7162: lt_dlopen (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB3FDE: lt_dlpreload_open (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5B9A: lt_dlinit (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== 8 bytes in 1 blocks are still reachable in loss record 2 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB801A: lt__slist_box (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB4347: lt_dlloader_add (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5A67: ??? (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB3FEB: lt_dlpreload_open (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5B9A: lt_dlinit (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== 8 bytes in 1 blocks are still reachable in loss record 3 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB801A: lt__slist_box (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== 9 bytes in 1 blocks are still reachable in loss record 4 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB40FA: lt__malloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB41F1: lt__memdup (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB4250: lt__strdup (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB4FB9: ??? (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB6AF7: ??? (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB6F8C: lt_dlopenadvise (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB7162: lt_dlopen (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB3FDE: lt_dlpreload_open (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5B9A: lt_dlinit (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== 20 bytes in 1 blocks are still reachable in loss record 5 of 8
==11805==    at 0x402A629: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AE03AD: _dlerror_run (dlerror.c:142)
==11805== 
==11805== 36 bytes in 1 blocks are still reachable in loss record 6 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB40FA: lt__malloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB4145: lt__zalloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB845B: dlopen_LTX_get_vtable (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5A56: ??? (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB3FEB: lt_dlpreload_open (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5B9A: lt_dlinit (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== 44 bytes in 2 blocks are still reachable in loss record 7 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB40FA: lt__malloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== 48 bytes in 1 blocks are still reachable in loss record 8 of 8
==11805==    at 0x402BB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==11805==    by 0x4AB40FA: lt__malloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB4145: lt__zalloc (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB6A60: ??? (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB6F8C: lt_dlopenadvise (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB7162: lt_dlopen (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB3FDE: lt_dlpreload_open (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x4AB5B9A: lt_dlinit (in /usr/lib/i386-linux-gnu/libltdl.so.7.3.0)
==11805==    by 0x6800315E: ???
==11805== 
==11805== LEAK SUMMARY:
==11805==    definitely lost: 0 bytes in 0 blocks
==11805==    indirectly lost: 0 bytes in 0 blocks
==11805==      possibly lost: 0 bytes in 0 blocks
==11805==    still reachable: 180 bytes in 9 blocks
==11805==         suppressed: 0 bytes in 0 blocks
==11805== 
==11805== For counts of detected and suppressed errors, rerun with: -v
==11805== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Even if I just do the MagickWandGenesis() and MagickWandTerminus() I still get the blocks still reachable. I'm planning to write a program using this as the template, and I would like to have a perfectly clean report from valgrind before starting so that all future findings will be my own bugs and I'll know which ones I need to work on. Is this "still reachable" memory a problem that's going to be addressed, or has it been addressed and I'm calling it wrongly? Thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: valgrind reporting: blocks still reachable with magickwa

Post by magick »

There is an errant atexit() handler in the Jasper library which can cause a fault if we call the Libtool lt_dlexit() method to clean up memory in the dynamic module loader. To fix, either build ImageMagick without support for the Jasper library or build ImageMagick without module support (the default build).
Post Reply