testsuite/gtk/templates.c crashes with segfault if a window takes unexpectedly long to be shown
Steps to reproduce
Run GTK test suite on a slow machine (I'm told it is readily reproducible in riscv64), or on an ordinary x86_64 with a home directory containing many files. The templates
test often segfaults. The downstream bug reporter writes: The segmentation fault appears because "surface.display" is 0xcfcfcfcfcfcfcfcf, which sounds like some memory poisoning.
test_page_setup_unix_dialog_show()
does this:
widget = gtk_page_setup_unix_dialog_new ("Setup your Page !", NULL);
g_assert_true (GTK_IS_PAGE_SETUP_UNIX_DIALOG (widget));
show_and_wait (widget);
gtk_window_destroy (GTK_WINDOW (widget));
where show_and_wait()
just sets the widget visible and then iterates the main loop for 500ms: it makes no attempt to wait until the dialog has actually been shown.
Workaround
I'm told that extending the arbitrary timeout from 500ms to 1500ms is enough to make the test pass on the machines where it was reproduced.
Version information
4.10.5 as packaged in Debian
Backtrace
| Program terminated with signal SIGSEGV, Segmentation fault.
| #0 0x0000003f839b65f6 in gdk_surface_get_display (surface=surface@entry=0x2b02537d50) at ../../../gdk/gdksurface.c:1033
| 1033 g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
| [Current thread is 1 (Thread 0x3f824e7480 (LWP 935442))]
| (gdb) bt full
| #0 0x0000003f839b65f6 in gdk_surface_get_display (surface=surface@entry=0x2b02537d50) at ../../../gdk/gdksurface.c:1033
| __inst = 0x2b02537d50
| __t = Python Exception <class 'gdb.error'>: No type named TypeNode.
|
| __r = <optimized out>
| _g_boolean_var_27 = <optimized out>
| __func__ = "gdk_surface_get_display"
| #1 0x0000003f8396fbc2 in frame_callback (data=0x2b02537d50, callback=0x2b03119030, time=286776601) at ../../../gdk/wayland/gdksurface-wayland.c:255
| surface = 0x2b02537d50
| impl = 0x2b02537d50
| display_wayland = <optimized out>
| clock = <optimized out>
| timings = <optimized out>
| #2 0x0000003f82a01264 in () at /usr/lib/riscv64-linux-gnu/libffi.so.8
| #3 0x0000003f82a00ebe in () at /usr/lib/riscv64-linux-gnu/libffi.so.8
| #4 0x0000003f82abc91c in () at /usr/lib/riscv64-linux-gnu/libwayland-client.so.0
| #5 0x0000003f82ab9c9a in () at /usr/lib/riscv64-linux-gnu/libwayland-client.so.0
| #6 0x0000003f82abae2e in wl_display_dispatch_queue_pending () at /usr/lib/riscv64-linux-gnu/libwayland-client.so.0
| #7 0x0000003f8396993e in _gdk_wayland_display_queue_events (display=0x2b01effe10) at ../../../gdk/wayland/gdkeventsource.c:218
| display_wayland = 0x2b01effe10
| source = 0x2b01f01050
| l = <optimized out>
| __func__ = "_gdk_wayland_display_queue_events"
| #8 0x0000003f8399df5c in gdk_display_get_event (display=0x2b01effe10) at ../../../gdk/gdkdisplay.c:461
| __func__ = "gdk_display_get_event"
| #9 0x0000003f8396966c in gdk_event_source_dispatch (base=<optimized out>, callback=<optimized out>, data=<optimized out>) at ../../../gdk/wayland/gdkeventsource.c:138
| source = <optimized out>
| display = <optimized out>
| event = <optimized out>
| #10 0x0000003f8352323c in () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #11 0x0000003f83525972 in () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #12 0x0000003f83525e26 in g_main_context_iteration () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #13 0x0000002ad6774f6a in show_and_wait (widget=0x2b021622e0) at ../../../testsuite/gtk/templates.c:47
| done = 0
| widget = 0x2b021622e0
| __func__ = "test_page_setup_unix_dialog_show"
| #14 test_page_setup_unix_dialog_show () at ../../../testsuite/gtk/templates.c:398
| widget = 0x2b021622e0
| __func__ = "test_page_setup_unix_dialog_show"
| #15 0x0000003f83545f9e in () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #16 0x0000003f83545e5a in () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #17 0x0000003f83545e5a in () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| --Type <RET> for more, q to quit, c to continue without paging--
| #18 0x0000003f83546344 in g_test_run_suite () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #19 0x0000003f835463ac in g_test_run () at /usr/lib/riscv64-linux-gnu/libglib-2.0.so.0
| #20 0x0000002ad6773fe0 in main (argc=<optimized out>, argv=<optimized out>) at ../../../testsuite/gtk/templates.c:473
| __func__ = "main"