Segmentation fault loading PDF - OSX, threaded, magickwand
Posted: 2011-11-17T05:34:32-07:00
Hi,
I have some code which uses the glib threadpool API and the ImageMagick magick wand api. It runs on Linux and OSX and mostly deals with EPS and PDF formats.
On OSX when running in a thread and loading a PDF I get a segmentation fault. Using the same code under linux I do not. If I load other formats I also still get no fault. Also if I remove the threading element I also get no segfault.
I have boiled this down to the following simple test program which demonstrates the issue (correct /tmp/in.pdf to whatever):
On the crashing machine I am using the ports version of image magick ( 6.7.3-1 ). Tried several PDFs so I don't think the contents are important, but I can supply one if needed.
Thanks!
Joe
I have some code which uses the glib threadpool API and the ImageMagick magick wand api. It runs on Linux and OSX and mostly deals with EPS and PDF formats.
On OSX when running in a thread and loading a PDF I get a segmentation fault. Using the same code under linux I do not. If I load other formats I also still get no fault. Also if I remove the threading element I also get no segfault.
I have boiled this down to the following simple test program which demonstrates the issue (correct /tmp/in.pdf to whatever):
Code: Select all
#include <glib.h>
#include <wand/magick-wand.h>
void process_request( gpointer data, gpointer mydata );
int main(void){
g_thread_init(NULL);
MagickWandGenesis();
GMainLoop * gmlp = g_main_loop_new( NULL, FALSE );
GError * e = NULL;
GThreadPool * pool = g_thread_pool_new( process_request,
NULL,
6,
FALSE,
&e);
g_thread_pool_push( pool, g_strdup("/tmp/in.pdf"), NULL );
g_main_loop_run ( gmlp );
}
void process_request( gpointer data, gpointer mydata )
{
gchar * in;
gsize len;
g_file_get_contents( (gchar*) data,
&in,
&len,
NULL );
MagickWand * wand = NewMagickWand();
g_warning("about to segfault...");
MagickReadImageBlob( wand,
in,
len );
g_warning("No I am fine!");
gchar * fmt = MagickGetImageFormat( wand );
g_warning( "%s", fmt );
}
Thanks!
Joe