gthread and pthread problem
- From: Chungfan Kim <ckim jaist ac jp>
- To: gtk-list redhat com
- Subject: gthread and pthread problem
- Date: Fri, 06 Aug 1999 15:32:01 +0900
Hi,
I posted a question posing a problem about anormal behavior of
the menuitem when it was compiled with -lgthread and -lpthread
a week ago.
It was that the program becomes response-less when I click on the
menuitem if both libgthread and libpthread were used.
After a simple private analysis of this anormality, I found that
the problem is caused by a deadlock of mutex.
Let me give you an evidence that was given by gdb(DDD):
(gdb) where
#0 0x401ed164 in __syscall_sigsuspend ()
#1 0x402116cc in __DTOR_END__ ()
#2 0x40171e8f in __pthread_mutex_lock (mutex=0x8050188) at
restart.h:32 <-- HERE
#3 0x400aaaa4 in gtk_menu_item_select_timeout ()
#4 0x400aa846 in gtk_real_menu_item_select ()
#5 0x4011305d in gtk_marshal_NONE__NONE ()
#6 0x400d3953 in gtk_signal_real_emit ()
#7 0x400d1a6f in gtk_signal_emit ()
#8 0x40094798 in gtk_item_select ()
#9 0x400a9c96 in gtk_menu_item_select ()
#10 0x400ac900 in gtk_menu_shell_select_item ()
#11 0x400abb3c in gtk_menu_shell_button_press ()
#12 0x40112c29 in gtk_marshal_BOOL__POINTER ()
#13 0x400d3ad7 in gtk_signal_real_emit ()
#14 0x400d1a6f in gtk_signal_emit ()
#15 0x40109908 in gtk_widget_event ()
#16 0x400a4ff2 in gtk_propagate_event ()
#17 0x400a4178 in gtk_main_do_event ()
#18 0x4014ec6b in gdk_event_dispatch ()
#19 0x40231e12 in g_main_dispatch ()
#20 0x4023240b in g_main_iterate ()
#21 0x402325c1 in g_main_run ()
#22 0x400a3b6b in gtk_main ()
#23 0x8048a40 in main (argc=1, argv=0xbffff9c0) at test.c:34
(gdb)
I don't have any idea if the problem belongs to my own or libgthread.
However, let me report this as a fact that I encountered.
Here is a simple program to evaluate the problem:
BEGIN:"test.c"------------------------------------------------------
#include <stdio.h>
#include <gtk/gtk.h>
GtkItemFactoryEntry menu_of_menu[] = {
{ "/File", NULL, NULL, 0, "<Branch>" },
{ "/File/New", NULL, NULL, 0, NULL },
{ "/File/Open", NULL, NULL, 0, NULL },
{ "/File/Save", NULL, NULL, 0, NULL },
{ "/File/Save As", NULL, NULL, 0, NULL },
{ "/File/spl1", NULL, NULL, 0, "<Separator>" },
{ "/File/Exit", NULL, NULL, 0, NULL }
};
GtkWidget*
create_main_window (void);
void
main (int argc, char **argv) {
GtkWidget *main_window;
g_thread_init (NULL);
gtk_set_locale ();
gtk_init (&argc, &argv);
main_window = create_main_window ();
gtk_widget_show (main_window);
gdk_threads_enter ();
gtk_main ();
gdk_threads_leave ();
return;
}
GtkWidget*
create_main_window (void) {
GtkWidget
*main_window,
*fixed,
*menubar;
GtkItemFactory *item_factory;
gint menu_size = sizeof (menu_of_menu) / sizeof (menu_of_menu[0]);
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
fixed = gtk_fixed_new ();
gtk_widget_show (fixed);
gtk_container_add (GTK_CONTAINER (main_window), fixed);
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
NULL);
gtk_item_factory_create_items (item_factory, menu_size,
menu_of_menu, NULL);
menubar = gtk_item_factory_get_widget (item_factory, "<main>");
gtk_widget_show (menubar);
gtk_fixed_put (GTK_FIXED (fixed), menubar, 0, 0);
return main_window;
}
END:"test.c"------------------------------------------------------
While the code doesn't include any pthread functions, I need to
use them within my application. The code is provided only for
simplifying the situation.
I currently am taking a bypass to avoid the problem. That is not
to use gthread in my app.
Please compile test.c with:
gcc -g -o test test.c -lgtk -lgdk -lgthread -lpthread
Then, run it, click on the "File" and you would see what's wrong.
Otherwise, I'd like to hear that nothing was wrong.
And here is my development environment:
gcc-2.7.2.3
glibc-2.0.7-29
gtk+-1.2.1-5
libpthread-0.7
Regards,
--
Chungfan Kim / ckim@jaist.ac.jp
"Man needs, for his happiness, not only the enjoyment of this or that,
but hope and enterprise and change." -B.Russel
School of Knowledge Science, JAIST
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]