Thanks Chris. I tried to remove any function call in the compile_thread, i.e:
// Thread function // It is signaled to wake up for every 1 second gpointer motion_compile_thread(gpointer data) { ... while (TRUE) { if (!g_mutex_trylock(cp_mutex)) continue; g_cond_wait(compile_cv, cp_mutex); g_mutex_unlock(mutex); } Now that what the thread does is simply wake up every 1 second (signaled by the main thread) and go back to sleep. It STILL deadlocked!!! I tried running this on ubuntu 10.10, and it worked perfectly fine (no deadlock) I'm starting to think it's the bug of gtk+, or perhaps the kernel? btw, I'm using Arch Linux with Kernel 2.6.37(autogroup patched), Gtk+ 2.22. SI once suspect that it maybe something to do with the autogroup patch I'm using, so I switch to the default 2.6.37 kernel. The result is the same.. still deadlocks. frustrated ... (but glad that this didn't happen on ubuntu) Thanks, Wei-Ning Huang 2011/3/5 Chris Vine <ch...@cvine.freeserve.co.uk> > On Sat, 5 Mar 2011 11:58:23 +0800 > Wei-Ning Huang <aitjc...@gmail.com> wrote: > [snip] > > From what I can see, the program is stuck because the main thread > > locked a mutex in #3. > > But from the backtrace, the mutex seems to be locked by > > gtk_main_loop_run() which is something I can't control, > > and somehow it locked the same mutex as gdk_threads_enter()? any > > ideas? > > If it isn't recursion then somewhere in your '....' you probably have > out-of-order locking. > > I should start by making the gdk global lock 'Lock 1' and work from > there. In other words, don't call gdk_threads_enter() when you are > holding a lock of your own. Also, don't call gdk_threads_enter() in a > GTK+ signal handler because it will already be locked there. (But that > is not true of ordinary glib main loop events.) > > Best of all, don't use the global lock at all but instead invoke > callbacks in the main loop with g_idle_add(). This is a cleaner > design and also has the benefit of making your program portable to > windows and other non-X11 platforms. > > Chris > > > -- AZ Huang <http://berelent.blogspot.com/> _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list