[Gc] Occasionally crash with GraphicsMagick, ImageMagick.

Shi Jie Gung ksc91u_fr at yahoo.fr
Tue May 4 19:11:30 PDT 2010


I set GC to GraphicsMagick/ImageMagick's default memory allocator.
Like this:

#include <stdlib.h>
#include <magick/api.h>
#include <string.h>
#include <unistd.h>
#define GC_DEBUG
#ifdef GC_DEBUG
#include <gc/gc.h>
#include <gc/gc_allocator.h>
#undef malloc
#undef calloc
#undef free
#undef realloc
#define malloc(n) GC_MALLOC(n)
#define calloc(m,n) GC_MALLOC((m)*(n))
#define free(p) GC_FREE(p)
#define realloc(p,n) GC_REALLOC((p),(n))
#define CHECK_LEAKS() GC_gcollect()
#endif

int main(int argc, char** argv) {
    #ifdef GC_DEBUG
    GC_init();
    
    /*GM*/
    /*MagickAllocFunctions(GC_free,GC_malloc,GC_realloc);*/

    /*IM*/
    SetMagickMemoryMethods(\
(AcquireMemoryHandler)GC_malloc,\
(ResizeMemoryHandler)GC_realloc,\
(DestroyMemoryHandler)GC_free);

    #endif
    InitializeMagick(NULL);
    ImageInfo *info=(ImageInfo *)malloc(sizeof(ImageInfo));
    ExceptionInfo * excp=(ExceptionInfo*)malloc(sizeof(ExceptionInfo));

    GetImageInfo(info);
    GetExceptionInfo(excp);
    strcpy(info->filename,argv[1]);
    Image * tmp = ReadImage(info,excp);
    Image * ii=ResizeImage(tmp,100,100,BesselFilter,0.9f,excp);

    DestroyMagick();
    #ifdef GC_DEBUG
    CHECK_LEAKS();
    #endif
    return (EXIT_SUCCESS);
}

With ImageMagick, always crash with backtrace:

#0  0x00000001001ab74a in GC_free ()
#1  0x00000001000be22f in RelinquishMagickMemory ()
#2  0x00000001000a2eed in DestroyLinkedList ()
#3  0x000000010003c636 in GetConfigureOptions ()
#4  0x00000001000d4de0 in GetPolicyInfo ()
#5  0x00000001000d50eb in GetPolicyValue ()
#6  0x000000010010a49c in ResourceComponentGenesis ()
#7  0x00000001000bcc35 in MagickCoreGenesis ()

and with GraphicsMagick, "occasionally" crash with backtrace:
#0  0x00007fff8441d886 in __kill ()
#1  0x00007fff844bdeae in abort ()
#2  0x0000000100268d55 in GC_abort ()
#3  0x000000010025ed43 in GC_freehblk ()
#4  0x0000000100264824 in GC_free ()
#5  0x000000010008f57a in DestroyCacheNexus ()
#6  0x000000010008f5cb in CloseCacheView ()
#7  0x000000010008f684 in DestroyThreadViewSet ()
#8  0x000000010007db8a in DestroyImage ()
#9  0x00000001000aba5f in ResizeImage ()
#10 0x0000000100000eb1 in main (argc=2, argv=0x7fff5fbff240) at main.cpp:50

and sometimes with
#0  0x000000010025e579 in GC_allochblk_nth ()
#1  0x000000010025e9e5 in GC_allochblk ()
#2  0x000000010026498e in GC_alloc_large ()
#3  0x0000000100264d8f in GC_generic_malloc ()
#4  0x0000000100264f23 in GC_core_malloc ()
#5  0x0000000100265c2d in GC_realloc ()
#6  0x00000001000858f5 in MagickRealloc ()
#7  0x0000000100090779 in SetNexus ()
#8  0x0000000100091408 in AcquireCacheNexus ()
#9  0x0000000100091d1b in AcquireCacheViewPixels ()
#10 0x00000001000ada9c in HorizontalFilter.omp_fn.1 ()
#11 0x00000001000ab608 in HorizontalFilter ()
#12 0x00000001000abb78 in ResizeImage ()
#13 0x0000000100000eb1 in main (argc=2, argv=0x7fff5fbff240) at main.cpp:50

with boehmgc-devel @7.2alpha2 macport 
ImageMagick @6.6.1-5, GraphicsMagick @1.3.12r1
Mac OS X 10.6.3 gcc-mp-4.5 

Could you help to debug this, thanks.


      



More information about the Gc mailing list