You are not logged in.

#1 2010-02-10 21:07:45

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

GD causing program to die with threading

I've been working on a fractal generator for the past few days and decided to add multithreading support tonight—just one problem, this code works perfectly without threads, and not all with threads:

Works:

    thread_options_t *toptions = (thread_options_t*)malloc(sizeof(thread_options_t));
    toptions->ioptions = ioptions;
    toptions->foptions = foptions;

    init_gd(&toptions->ioptions);
    fractal_main_loop(toptions->foptions, toptions->ioptions);
    save_set(toptions->ioptions);

Doesn't work:

    thread_options_t *toptions = (thread_options_t*)malloc(sizeof(thread_options_t));
    toptions->ioptions = ioptions;
    toptions->foptions = foptions;

    pthread_t threadid;
    pthread_create(&threadid, NULL, spawn_fractal_generator, (thread_options_t*)toptions);

Where spawn_fractal_generator is this function:

void *spawn_fractal_generator(void* arg)
{
    thread_options_t *toptions = (thread_options_t*)arg;

    init_gd(&toptions->ioptions);
    fractal_main_loop(toptions->foptions, toptions->ioptions);
    save_set(toptions->ioptions);

    pthread_exit(0);
}

I've found that it's the init_gd() call which is failing, init_gd() is this:

void init_gd(image_options_t *ioptions)
{
    ioptions->gd.im = gdImageCreateTrueColor(ioptions->image.width, ioptions->image.height);
}

Putting printfs before and after the call to gdImageCreateTrueColor() shows that the program just dies somewhere in that call: but with no error message and with a return code of 0.

Last edited by Barrucadu (2010-02-10 21:10:36)

Offline

#2 2010-02-13 08:51:30

gradgrind
Member
From: Germany
Registered: 2005-10-06
Posts: 921

Re: GD causing program to die with threading

I noticed something similar after some update or other on one machine using threads in python. Could it be a glibc problem?

Offline

Board footer

Powered by FluxBB