LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Unable to fix crashes in a GUI using GTK2.0 (https://www.linuxquestions.org/questions/programming-9/unable-to-fix-crashes-in-a-gui-using-gtk2-0-a-383235/)

stephenwalter 11-15-2005 12:26 AM

Unable to fix crashes in a GUI using GTK2.0
 
Hi,
Iam working on a client server application using c , and i have developed a GUI for my application using GTK2.0 . I face a segmentation fault sometimes but not all the times and i tried to backtrace the segmentation fault using gdb and this was what gdb traced out .

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208247840 (LWP 3244)]
0x007e4ccf in malloc_consolidate () from /lib/libc.so.6
(gdb) backtrace
#0 0x007e4ccf in malloc_consolidate () from /lib/libc.so.6
#1 0x007e608d in _int_malloc () from /lib/libc.so.6
#2 0x007e7792 in malloc () from /lib/libc.so.6
#3 0x00b48a00 in g_malloc () from /usr/lib/libglib-2.0.so.0
#4 0x00d5c9fd in pango_log2vis_get_embedding_levels () from /usr/lib/libpango-1.0.so.0
#5 0x00d4b724 in pango_context_get_base_dir () from /usr/lib/libpango-1.0.so.0
#6 0x00d4c354 in pango_itemize_with_base_dir () from /usr/lib/libpango-1.0.so.0
#7 0x00d53459 in pango_layout_iter_get_char_extents () from /usr/lib/libpango-1.0.so.0
#8 0x00d54007 in pango_layout_iter_get_char_extents () from /usr/lib/libpango-1.0.so.0
#9 0x00289d39 in gtk_text_layout_get_line_display () from /usr/lib/libgtk-x11-2.0.so.0
#10 0x002804a3 in gtk_text_layout_draw () from /usr/lib/libgtk-x11-2.0.so.0
#11 0x00299890 in gtk_text_view_scroll_to_iter () from /usr/lib/libgtk-x11-2.0.so.0
#12 0x0020c352 in gtk_marshal_VOID__UINT_STRING () from /usr/lib/libgtk-x11-2.0.so.0
#13 0x00cbdd9b in g_cclosure_new_swap () from /usr/lib/libgobject-2.0.so.0
#14 0x00cbe285 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#15 0x00ccc917 in g_signal_stop_emission () from /usr/lib/libgobject-2.0.so.0
#16 0x00ccdc53 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#17 0x00cce254 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#18 0x002e7ac3 in gtk_widget_activate () from /usr/lib/libgtk-x11-2.0.so.0
#19 0x0020b0cb in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#20 0x00da25ad in gdk_window_clear_area_e () from /usr/lib/libgdk-x11-2.0.so.0
#21 0x00da2680 in gdk_window_process_all_updates () from /usr/lib/libgdk-x11-2.0.so.0
#22 0x00da2701 in gdk_window_process_all_updates () from /usr/lib/libgdk-x11-2.0.so.0
#23 0x00b44650 in g_child_watch_add () from /usr/lib/libglib-2.0.so.0
#24 0x00b423ee in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#25 0x00b453f6 in g_main_context_check () from /usr/lib/libglib-2.0.so.0
#26 0x00b456e3 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#27 0x0020a1b5 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#28 0x0804ca81 in main (argc=1, argv=0xbfdd5fb4) at menu.c:709

menu.c is where i have the entry point for my application.

Since the crash is not happening always iam not able to guess the reason for the crash. If anyone who is working on GTK2.0 or anyone who knows a way in which this can be solved please let me know. Thanking u all in anticipation.

Regards,

S.Suresh Stephen

Ygrex 11-17-2005 08:01 AM

The more probable reason is you work with an unallocated memory. Do you use
malloc() or calloc()? Do you free() memory? May be you incorrectly (or do not
at all) assign values for pointers and, meantime, use them?

stephenwalter 11-19-2005 12:06 AM

Hi,
Sorry for not responding quickly i was on leave. Let me explain the issue more clearly, I have a main window which has a menu bar and in in one of the menus i have a menu item which when activated will open a window and when the ok button that i have created is pressed it will open another window and when the ok button that i have created is pressed it will open another window(so 3 windows) now what happens is for the switch from first to second window no issues from there to the third there is a crash and in gdb backtrace it points to the malloc() and some times free() or realloc() . I have not used any malloc() for creating the UI . I dont understand the reason at all. And sometimes it does not crash and application executes successfully.

Regards,

S.Suresh Stephen

Ygrex 11-19-2005 06:18 AM

I never worked with gdb, please post there output produced by valgrind.
Otherwise, it seems, I cannot help.

stephenwalter 11-20-2005 07:02 AM

Hi,
Thanks for ur reply . I found the issue for the crash. The crash was rather because of an malloc() in GUI . When i changed that char pointer to an array. The issue was resolved. Thanks for ur help any way.

Regards,

S.Suresh Stephen


All times are GMT -5. The time now is 09:51 PM.