Hi all
** Please CC replies to me since my mail volume prevents me from
subscribing to this list to observe any replies. Thanks.
I have encountered a strange problem when some software I am developing is
statically linked against XFree86 4.2.0 and 4.2.1: basically, the program
segfaults very soon after starting, but ONLY if it has been statically
linked.
Included at the bottom of this message is source to a cut-down application
which exhibits the problem. Unfortunately it uses gtk since I don't know
enough lowlevel X11 programming to make a standalone application to
demonstrate the problem. This program segfaults for me when statically
linked when a third dropdown menu is activated. In other words, the first
two menus you try to display work fine, and then a segfault occurs when a
third is activated.
The problem does not occur if the executable is dynamically linked - only a
statically linked executable does this. Furthermore, it doesn't happen if
the executable is statically linked against libX11 from XFree 4.1.0.
If I statically link against Xfree86 4.2.0's X11, I can prevent the segfault
by removing /usr/X11R6/lib/X11/locale/common/xlcDef.so.2. Thus it seems to
be something to do with the dynamic locale functionality which was added in
Xfree86 4.2.x. Either the functionality itself or the use of text functions
which indirectly call the locale stuff would seem to be at fault.
I don't know where to go from here and any suggestions would be helpful. I
can also run further tests if required.
The coredump I get from this problem indicates the following:
#0 0x0811ade0 in __libc_free (mem=0x820f010) at malloc.c:3151
#1 0x080ef100 in XmbSetWMProperties ()
#2 0x080ba7e3 in gdk_window_new ()
#3 0x080978f6 in gtk_window_realize ()
#4 0x08063ea4 in gtk_marshal_NONE__NONE ()
#5 0x0807bbe0 in gtk_signal_real_emit ()
#6 0x0807a221 in gtk_signal_emit ()
#7 0x0808e7a9 in gtk_widget_realize ()
#8 0x08097379 in gtk_window_show ()
#9 0x08063ea4 in gtk_marshal_NONE__NONE ()
#10 0x0807bbe0 in gtk_signal_real_emit ()
#11 0x0807a221 in gtk_signal_emit ()
#12 0x0808dd1b in gtk_widget_show ()
#13 0x08064b0c in gtk_menu_popup ()
#14 0x08068b79 in gtk_menu_item_popup_submenu ()
#15 0x08068ad1 in gtk_menu_item_select_timeout ()
#16 0x080c3ded in g_timeout_dispatch ()
#17 0x080c30c1 in g_main_dispatch ()
#18 0x080c365b in g_main_iterate ()
#19 0x080c37a3 in g_main_run ()
#20 0x080629ca in gtk_main ()
#21 0x080487e2 in main ()
#22 0x0810a775 in __libc_start_main (main=0x80487a0 <main>, argc=1,
ubp_av=0xbffff994, init=0x80480b4 <_init>, fini=0x8156600 <_fini>,
rtld_fini=0, stack_end=0xbffff98c) at ../sysdeps/generic/libc-start.c:129
I have sent a bugreport in using the webform but have not heard anything and
see no evidence in CVS that this has been addressed. I am not at this stage
even sure that the fault doesn't lie in gtk - any suggestions or pointers
would be appreciated (although the fact that it can be prevented by
reverting to an earlier libX11 is suspicious).
If anyone can give any further insight into this problem it would be very
much appreciated.
Best regards
jonathan
=== Source follows ===
/*
* A small test program to illustrate a segfault when compiled on Slackware
* 8.1 as a static application.
*
* To compile, use the following Makefile contents:
* CC=gcc
* all: gtktest
* gtktest: gtktest.o
* $(CC) -o gtktest -static gtktest.o `gtk-config --libs`
* # Intermediate C files
* %.o: %.c
* $(CC) -o $@ -c $< -Wall \
* `gtk-config --cflags`
*
* When compiled under Slackware 8.0, the program is fine. However, if
* compiled under Slackware 8.1 a segfault will occur after some menu
* operations. Usually clicking on the menu bar and dragging across it
* is enough to trigger the problem. Sometimes (but not always) the problem
* triggers on the end items ("File" and "Help").
*
*/
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
#define MMSG_INFO 10
#define MSIM_DISCON 20
#define MHLP_ABOUT 30
static void menu_handler(GtkWidget *w, gpointer data);
/* Main menu structure */
static GtkItemFactoryEntry menu_items[] = {
{ "/_File", NULL, NULL, 0, "<Branch>" },
{ "/File/_Quit", "<control>Q", gtk_main_quit, 0, NULL },
{ "/_Connection", NULL, NULL, 0, "<Branch>" },
{ "/Connection/_Disconnect",NULL, menu_handler, MSIM_DISCON, NULL},
{ "/_Stdout messages", NULL, NULL, 0, "<Branch>" },
{ "/Stdout messages/_Information", NULL, menu_handler, MMSG_INFO,
"<CheckItem>" },
{ "/_Help", NULL, NULL, 0, "<Branch>" },
{ "/Help/_About", NULL, menu_handler, MHLP_ABOUT, NULL},
};
void menu_handler(GtkWidget *w, gpointer data) {
}
/* ======================================================================== */
GtkWidget *setup_version_combobox() {
/*
* Purpose: creates a new version combobox widget.
*
*/
GList *list = NULL;
GtkWidget *w;
w = gtk_combo_new();
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(w)->entry),FALSE);
list = g_list_append(list,"1.0");
list = g_list_append(list,"1.1");
if (list != NULL) {
gtk_combo_set_popdown_strings(GTK_COMBO(w),list);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),list->data);
} else {
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),"");
}
if (list != NULL)
g_list_free(list);
return(w);
}
/* ======================================================================== */
void app_gui_init() {
/*
* Purpose: constructs the top-level application window.
*
*/
GtkWidget *rootwindow;
GtkWidget *menubar;
GtkWidget *vbox, *hbox;
GtkWidget *frame, *t;
GtkItemFactory *item_factory;
GtkAccelGroup *accel_group = gtk_accel_group_new();
int nitems = sizeof(menu_items) / sizeof(menu_items[0]);
/* Create the top-level root window */
rootwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(rootwindow),"Test GTK app");
gtk_signal_connect(GTK_OBJECT(rootwindow), "delete_event",
gtk_main_quit,NULL);
vbox = gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(rootwindow), vbox);
/* Construct the menu structure */
item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR,"<main>",accel_group);
gtk_item_factory_create_items(item_factory, nitems, menu_items, NULL);
gtk_window_add_accel_group(GTK_WINDOW(rootwindow), accel_group);
menubar = gtk_item_factory_get_widget(item_factory,"<main>");
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
/* Fiddle with boxes to effect an indent from the edges of the root window */
hbox = gtk_hbox_new(FALSE,0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 10);
vbox = gtk_vbox_new(FALSE,10);
gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 10);
/* Set up a details pane */
hbox = gtk_hbox_new(FALSE,0);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
frame = gtk_frame_new("Mirecat details");
gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, FALSE, 0);
t = gtk_table_new(3,2,FALSE);
gtk_container_add(GTK_CONTAINER(frame),t);
/* Populate the details frame */
gtk_table_attach(GTK_TABLE(t),
gtk_label_new("Computer type"),0,1,0,1, GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(t),
gtk_label_new("Monitor version"),0,1,1,2, GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(t),
gtk_label_new("HDD version"),0,1,2,3, GTK_FILL,0,0,0);
gtk_table_attach(GTK_TABLE(t),
setup_version_combobox(), 1,2,0,1,GTK_FILL,0,10,0);
gtk_table_attach(GTK_TABLE(t),
setup_version_combobox(), 1,2,1,2,GTK_FILL,0,10,3);
gtk_table_attach(GTK_TABLE(t),
setup_version_combobox(), 1,2,2,3,GTK_FILL,0,10,0);
gtk_widget_show_all(rootwindow);
}
/* ======================================================================== */
int main(int argc, char *argv[]) {
int gui_ok;
gui_ok = gtk_init_check(&argc, &argv);
printf("gui_ok = %d\n",gui_ok);
if (gui_ok) {
app_gui_init();
gtk_main();
}
return 0;
}
--
* Jonathan Woithe [EMAIL PROTECTED] *
* http://www.physics.adelaide.edu.au/~jwoithe *
***-----------------------------------------------------------------------***
** "Time is an illusion; lunchtime doubly so" **
* "...you wouldn't recognize a subtle plan if it painted itself purple and *
* danced naked on a harpsichord singing 'subtle plans are here again'" *
_______________________________________________
I18n mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/i18n