Threads and 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
javiersm

Threads and MagickWand

Post by javiersm »

Hi!

I'm developing an app that dones an image treatment and it shows the result in a browser following the next path:

http(browser) -> Apache -> Java Module -> JNA -> my Magickwand program.

And then it returns the result to the browser.

The problem is that when I run concurrent threads it fails and lost responses. I've config ImageMagick-6.4.8-3 with '--enable-threads=posix' so I dont understand where could be the problem. The stack trace that returns Java is:

Stack: [0x044b1000,0x04502000), sp=0x044fc744, free space=301k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x048a341c
C 0x048a5cb8
C [libMagickCore.so.1+0x52945] WriteImage+0x531
C [libMagickCore.so.1+0x2913c] ImageToBlob+0x1c4
C [libMagickWand.so.1+0x95f99] MagickGetImageBlob+0x55
C [libMagickWand.so.1+0x5c262] MagickWriteImageBlob+0x1e
C [libWrapWand.so+0xe6f] ImageAnnotate+0x23d
C [jna9504.tmp+0x10ec7] ffi_call_SYSV+0x17
C [jna9504.tmp+0x10b74] ffi_call+0xb4
C [jna9504.tmp+0x3671]
C [jna9504.tmp+0x3d20] Java_com_sun_jna_Function_invokePointer+0x43
j com.sun.jna.Function.invokePointer(I[Ljava/lang/Object;)Lcom/sun/jna/Pointer;+0

So it looks like it fails in 'MagickWriteImageBlob' function which i'm using in my program...

Any help will be apreciated, thanks!

Best regards.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Threads and MagickWand

Post by magick »

Theoretically ImageMagick is thread-safe. We'll try to reproduce the problem but will need a few days. If you can get your process to return a stack trace with line numbers, that would be helpful.
javiersm

Re: Threads and MagickWand

Post by javiersm »

Hi! Thanks for your support.

I don't know how to configure the log to return line numbers, sorry very much, I'll try. Meanwhile let me set out the problem with more detail, my C Program do this:

(C Code)

void* ImageAnnotate(int *iSizeOutput )
{

//this will be convert into a byte array for java.
unsigned char *psFileStreamOutput = NULL;

//Text treatment.

psFileStreamOutput = MagickGetImageBlob(wand_background, (size_t *)iSizeOutput );
return (void *)psFileStreamOutput;

}

and then I invoke this function:

void relinquishMem (void* p)
{
p = MagickRelinquishMemory(p);
}

Giving psFileStreamOutput to the function parameter, is this code ok?

I hope it will be helpful, thanks again.

best regards.
Post Reply