[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Debian 6 with Sudden GTK application crash @ libGDK



Very recently, we migrated from DEBIAN 5(Lenny) to DEBAIN 6(Squeeze). Since, our application is based on GTK 2.0 we thought migrating from GTK app is pretty easy.

So, as a first step we compiled our application and ran some regressions on the system.

Suddenly, we noticed application getting crash @ **libgdk-x11-2.0.so.0.2000.1**. This leaded system to crash at unexpected state.

core sample info:

    Program terminated with signal 11, Segmentation fault.
    #0  0xb708bb0c in ?? () from /usr/lib/libgdk-x11-2.0.so.0
    (gdb) bt
    #0  0xb708bb0c in ?? () from /usr/lib/libgdk-x11-2.0.so.0
    #1  0xb708bbb1 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
    #2  0xb7091797 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
    #3  0xb6e87381 in ?? () from /lib/libglib-2.0.so.0
    #4  0xb6e89305 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
    #5  0xb6e8cfe8 in ?? () from /lib/libglib-2.0.so.0
    #6  0xb6e8d527 in g_main_loop_run () from /lib/libglib-2.0.so.0
    #7  0xb7224e19 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
    #8  0x0813e25e in main_callback (data=0x0) at src/dispimage.c:59
    #9  0xb6eb36cf in ?? () from /lib/libglib-2.0.so.0
    #10 0xb7894955 in start_thread (arg=0xb27ffb70) at pthread_create.c:300
#11 0xb6c94e7e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130

From the received **CORE** ,we were not able to conclude what is causing the exact issue.

So, to fix this issue we ran various trials on the system and found that when DEBIAN 5(lenny's) LIBGDK-X11( **libgdk-x11-2.0.so.0.1200.11 ** ) and LIBGTK-X11 ( **libgtk-x11-2.0.so.0.1200.11** ) is used, the system does not crash.

However, when we run the system with mention configuration, we notice that **XORG** memory is increasing gradually and reaches to **SWAP** in hours of time.

DEBAIN 6 in with SQUEEZE's default repository GTK and GDK (libgdk-x11-2.0.so.0.2000.1):

MEMMORY Info:

    PID  USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+ COMMAND
    1520 root      19  -1 37504  27m 3676 S    6  5.6   3:11.65 Xorg
    1520 root      19  -1 37504  27m 3676 S    3  5.6   3:12.69 Xorg
    1520 root      19  -1 37504  27m 3676 S    4  5.6   3:15.06 Xorg
    1520 root      19  -1 37504  27m 3676 S    4  5.6   3:16.09 Xorg

LDD info: http://pastebin.com/s7F7cmSV

DEBAIN 6 with LENNY's default repository GTK and GDK (**libgdk-x11-2.0.so.0.1200.11**):

    PID   USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+ COMMAND
    11354 root      19  -1 39248  29m 3636 S    3  5.9   0:16.99 Xorg
    11354 root      19  -1 39380  29m 3636 S    4  5.9   0:17.10 Xorg
    11354 root      19  -1 39512  29m 3636 R    4  6.0   0:21.02 Xorg
    11354 root      19  -1 39640  29m 3636 S    3  6.0   0:22.68 Xorg

LDD info: http://pastebin.com/gwJhpEQe

Request ,some debugging model to understand and fix the root cause of the issue.

LDD info for LibGDK :

Sample GTK code that we use for TESTING:

Compiling: gcc -o dispText dispText.c `pkg-config --libs --cflags gtk+-2.0 --libs --cflags gthread-2.0`

    #include <gtk/gtk.h>
    #include <string.h>
    #include <stdio.h>
    #include <pthread.h>

    GtkWidget *window;
    pthread_t fsmThreadId;
    void destroyWidget(int index)
    {
        GList *children, *iter;
        children = gtk_container_get_children(GTK_CONTAINER(window));
        for(iter = children; iter != NULL; iter = g_list_next(iter)){
 gtk_container_remove(GTK_CONTAINER(window),GTK_WIDGET(iter->data));
            printf("Deleting Widget\n");
        }
    g_list_free(iter);
    g_list_free(children);
    }

    int dispTextPage(char* tempfileName, int pixBufOperation)
    {
        int index;
        GtkWidget *textv;
        GdkWindow *textv_window;
        GdkPixmap *pixmap = NULL;
        GtkTextBuffer* textBuffer=NULL;

        /* Lock thread */
        gdk_threads_enter();
        GdkColor color;

        char tempBuffer[512];
        char newfName[100]={'\0'};
        char ext[4]={'\0'};
        char temp[100]={'\0'};
        int i;
        char fileName[256];
        FILE * fd;
        int imageFound = 1;
        int lastSeperatorIndex = 0,j = 0;

        memset(fileName,0,sizeof(fileName));
        strcpy(fileName,tempfileName);
        /* Currently destroing the widget here itself */
        /* Since we are using widgets one by one currently */
        destroyWidget(1);

        textv = gtk_text_view_new ();
        gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textv), 28);
        gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textv), 20);
 gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(textv),1);
        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textv), GTK_WRAP_CHAR);

gtk_text_view_set_justification(GTK_TEXT_VIEW(textv), GTK_JUSTIFY_LEFT);
        gtk_text_view_set_editable(GTK_TEXT_VIEW(textv), FALSE);
        gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textv), FALSE);

        gtk_container_add(GTK_CONTAINER(window), textv);

textv_window = gtk_text_view_get_window (GTK_TEXT_VIEW (textv), GTK_TEXT_WINDOW_TEXT);
        gdk_color_parse ("#68604d", &color);
        //Method 1 : XORG VIRTUAL MEMORY grows
        if(pixBufOperation==0)
        {
pixmap = gdk_pixmap_create_from_xpm ((GdkDrawable *) textv_window, NULL, &color, fileName);
            gdk_window_set_back_pixmap (textv_window, pixmap, FALSE);
            g_object_unref(pixmap);
        }
        //METHOD 2 : XORG MEMORY GROWS 132KB per minute
        else
        {
            GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (fileName, NULL);
            gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, NULL, 0);
            gdk_window_set_back_pixmap (textv_window, pixmap, FALSE);
            g_object_unref (pixbuf);
            g_object_unref (pixmap);
        }

        textBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textv));
gtk_text_buffer_create_tag (textBuffer, "bold", "foreground", "Black", NULL); gtk_text_buffer_create_tag (textBuffer, "Redbold", "foreground", "Red",NULL); gtk_text_buffer_create_tag (textBuffer, "whiteBold", "foreground", "White",NULL); gtk_text_buffer_create_tag (textBuffer, "fontSize", "font", "saxmono 27.5", NULL); gtk_text_buffer_create_tag (textBuffer, "fontweight", "weight", 1000, NULL);
        gtk_widget_show(textv);
/* Set the min timeout and break the gtk loop to return the control to the caller */
        gtk_widget_show(window);
        /* Unlock thread */
        gdk_threads_leave();
        return index;
    }

    gpointer main_callback(gpointer data)
    {
        gtk_main();
        return 0;
    }

    void dispInit(int argc, char* argv[])
    {
        gtk_init (&argc, &argv);
        g_thread_init(NULL);
        gdk_threads_init();
        gdk_threads_enter();
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_resize((GtkWindow*)window, 800, 600);
        gtk_widget_realize( window );
        gtk_window_set_decorated((GtkWindow*)window, FALSE);
        g_thread_create(main_callback, NULL, FALSE, NULL);
        /* Unlock Thread */
        gdk_threads_leave();

    }

    void *fsmThread_RunFunction(void *threadid)
    {
        sleep(10);
        while (1)
        {
        dispTextPage("/opt/images/NotEnabled.gif",0);
        sleep(1);
        dispTextPage("/opt/images/Error.gif",0);
        sleep(1);
        }
    }


    int main (int argc, char **argv)
    {
        GError *error = NULL;
        size_t stacksize;
        pthread_attr_t attr;
        long t=1;
        printf("fsmThreadId");

        pthread_attr_init(&attr);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
        pthread_attr_getstacksize (&attr, &stacksize);
        stacksize = sizeof(char)*10*1024*1024;

        pthread_attr_setstacksize (&attr, stacksize);

if( pthread_create(&fsmThreadId, &attr, fsmThread_RunFunction, (void *)t) )
        {
            exit(-1);
        }

        printf("fsmThreadId created");

        dispInit(argc,argv);
        if(pthread_join(fsmThreadId, NULL))
        {
        exit(-1);
        }
    }







Reply to: