Debugging a GTK/GDK freeze

I have a GTK 3 app whose main thread sometimes freezes with a stack trace like this:

35 lines
#0  0x00007f8d614e3aff in __GI___poll (fds=0x7ffc40d00188, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f8d60a86c1a in  () at /lib/x86_64-linux-gnu/
#2  0x00007f8d60a8861f in  () at /lib/x86_64-linux-gnu/
#3  0x00007f8d60a88796 in xcb_wait_for_reply64 () at /lib/x86_64-linux-gnu/
#4  0x00007f8d6117fee8 in _XReply () at /lib/x86_64-linux-gnu/
#5  0x00007f8d6117b7f1 in XSync () at /lib/x86_64-linux-gnu/
#6  0x00007f8d61856f86 in find_current_serial (xdisplay=0x2667f20) at ../../../../../gdk/x11/gdkgeometry-x11.c:107
#7  gdk_window_queue (new_item=0x2a0c110, window=0x2815c70 [GdkX11Window]) at ../../../../../gdk/x11/gdkgeometry-x11.c:167
#8  _gdk_x11_window_queue_antiexpose (window=0x2815c70 [GdkX11Window], area=<optimized out>) at ../../../../../gdk/x11/gdkgeometry-x11.c:224
#9  0x00007f8d618354a9 in gdk_window_process_updates_internal (window=0x2815c70 [GdkX11Window]) at ../../../../gdk/gdkwindow.c:4018
#10 0x00007f8d61835674 in gdk_window_process_updates_with_mode (recurse_mode=<optimized out>, window=<optimized out>) at ../../../../gdk/gdkwindow.c:4215
#11 gdk_window_process_updates_with_mode (window=<optimized out>, recurse_mode=<optimized out>) at ../../../../gdk/gdkwindow.c:4186
#12 0x00007f8d621d9a56 in _g_closure_invoke_va (closure=0x29502d0, return_value=0x0, instance=0x269e410, args=0x7ffc40d007a0, n_params=0, param_types=0x0)
    at ../../../gobject/gclosure.c:873
#13 0x00007f8d621f8b48 in g_signal_emit_valist (instance=0x269e410, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7ffc40d007a0)
    at ../../../gobject/gsignal.c:3408
#14 0x00007f8d621f90f3 in g_signal_emit (instance=instance@entry=0x269e410, signal_id=<optimized out>, detail=detail@entry=0)
    at ../../../gobject/gsignal.c:3555
#15 0x00007f8d6182c3b3 in _gdk_frame_clock_emit_paint (frame_clock=frame_clock@entry=0x269e410 [GdkFrameClockIdle]) at ../../../../gdk/gdkframeclock.c:643
#16 0x00007f8d6182ccf3 in gdk_frame_clock_paint_idle (data=0x269e410) at ../../../../gdk/gdkframeclockidle.c:450
#17 0x00007f8d61816f4d in gdk_threads_dispatch (data=0x2a10400, data@entry=<error reading variable: value has been optimized out>)
    at ../../../../gdk/gdk.c:769
#18 0x00007f8d620eebe8 in g_timeout_dispatch (source=0x2a13d10, callback=<optimized out>, user_data=<optimized out>) at ../../../glib/gmain.c:4800
#19 0x00007f8d620ee04e in g_main_dispatch (context=0x268f9b0) at ../../../glib/gmain.c:3309
#20 g_main_context_dispatch (context=context@entry=0x268f9b0) at ../../../glib/gmain.c:3974
#21 0x00007f8d620ee400 in g_main_context_iterate (context=0x268f9b0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../../../glib/gmain.c:4047
#22 0x00007f8d620ee6f3 in g_main_loop_run (loop=0x2a604b0) at ../../../glib/gmain.c:4241
#23 0x00007f8d61b3937d in gtk_main () at ../../../../gtk/gtkmain.c:1328
#24 0x00000000004eb7f0 in runtime.asmcgocall () at /home/vasiliy/cur/ware/go/1.16/src/runtime/asm_amd64.s:667
#25 0x000000c000010530 in  ()
#26 0x000000000085cfa0 in runtime.m0 ()
#27 0x000000c00013ddd8 in  ()
#28 0x0000000000000001 in  ()
#29 0x000000c00013dde8 in  ()
#30 0x0000000000000120 in  ()
#31 0x000000c000000180 in  ()
#32 0x000000001adfcbda in  ()
#33 0x00000000004bcb80 in runtime.mstart () at /home/vasiliy/cur/ware/go/1.16/src/runtime/signal_unix.go:1035
#34 0x00000000004e9c14 in runtime.rt0_go () at /home/vasiliy/cur/ware/go/1.16/src/runtime/asm_amd64.s:226
#35 0x0000000000000000 in  ()

This happens around the time when the program is doing work and UI updates, mostly GtkProgressBar updates. But I can’t easily reproduce it on demand. It doesn’t seem to happen when I run the program in a loop imitating work without user input.

Still, I get this often enough in regular usage — perhaps once a week — that I might be able to debug it, slowly.

Can you advise me on how to debug such a freeze? What logging or tracing should I add or enable? What should I look at the next time I catch it?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.