gtk+-2.0 + pthreads = crash

Hi everybody,

I’ve got a small gtk+ program that is driving me up the wall, it crashes in a quite a few different ways which leads me to believe that the interaction of the threads is producing some unexpected behaviors. I suppose there could be a buffer overflow somewhere in my C code, but the arrays are really simple and there is hardly any dynamic memory in it, and I am pretty unfamiliar with threads so I think that is where my error is more likely to be. The stack traces tend to show the error occurring in gtk+ functions, which makes it hard to figure out where I am screwing up.

However I just kind of noticed that there is a gthreads library, and I just started building with it and so I am calling g_thread_init(NULL) at the start of the program, which did improve things a little bit (I’m at least getting more meaningful error messages now) but I am still using all the pthread code from before I realized there was a gthread library. Is this causing my problem? It wouldn’t be that hard to rewrite this but I’d rather not do it only to end up in the same spot I am in right now only with a different threads library.

Also, I feel like I’ve been getting all the relevant debug packages I can find and I’m still not getting function names in the stack trace for this stuff:

#3  0x00007ffff4481c76 in ?? () from /lib64/
#7  0x00007ffff79209f8 in ?? () from /usr/lib64/
#14 0x00007ffff757628a in ?? () from /usr/lib64/

I do get function names for other functions in libc and libgtk-x11-2.0, but I don’t see any function names for any in the libgdk-x11-2.0. I think I must just be missing a debug package or two, I have plenty of disk space so I was wondering if there wasn’t a metapackage or two that I could get that would just give me all the ones a might need even if I end up with a whole bunch that I don’t need.

Thanks for any help,

Oh ok, I figured it out. For the record the problem as that I had to make an initial call to “gdk_init_threads();” right after the call to “g_thread_init(NULL);”, and then I had to wrap the call to “gtk_main();”, and any code other than signal handlers that use any of the gtk API (for me it was just one function), inside of calls to “gdk_threads_enter();” and “gdk_threads_leave();”.

On a side note, I am of the opinion that requiring people to use one set of thread functions which use “thread” in the singular (gthread or pthread), and another which uses “threads” in the plural (gdk_threads) is not nice.

Thx anyway,