Skip to content

events: Protect against error from XGetWMHints()

sfan5 requested to merge (removed):master into master

This fixes the following crash:

(xfwm4:1517146): Gdk-ERROR **: 17:18:24.795: The program 'xfwm4' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 40156 error_code 3 request_code 20 (core protocol) minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

Thread 1 "xfwm4" received signal SIGTRAP, Trace/breakpoint trap.
#0  0x00007ffff6f4b294 in g_log_writer_default () at /usr/lib/
#1  0x00007ffff6f48ae9 in g_log_structured_array () at /usr/lib/
#2  0x00007ffff6f49041 in g_log_structured_standard () at /usr/lib/
#3  0x00007ffff75c3577 in  () at /usr/lib/
#4  0x00007ffff6dd2a3b in _XError () at /usr/lib/
#5  0x00007ffff6dcf6b8 in  () at /usr/lib/
#6  0x00007ffff6dd09a9 in _XReply () at /usr/lib/
#7  0x00007ffff6db5f16 in XGetWindowProperty () at /usr/lib/
#8  0x00007ffff6db4c87 in XGetWMHints () at /usr/lib/
#9  0x000055555557a8c2 in handlePropertyNotify (ev=0x7fffffffd610, display_info=0x5555558a3b70) at events.c:1712
        status = EVENT_FILTER_REMOVE
        screen_info = 0x5555558a4a00
        c = 0x555555f3bc70
        status = EVENT_FILTER_STOP
        status = <optimized out>
        display_info = 0x5555558a3b70
#10 handleEvent (event=0x555555f395e0, display_info=0x5555558a3b70) at events.c:2264
        status = EVENT_FILTER_STOP
        status = <optimized out>
        display_info = 0x5555558a3b70
#11 xfwm4_event_filter (event=0x555555f395e0, data=0x5555558a3b70) at events.c:2327
        status = <optimized out>
        display_info = 0x5555558a3b70
#12 0x0000555555577758 in eventXfwmFilter (gdk_xevent=<optimized out>, gevent=<optimized out>, data=<optimized out>)
    at event_filter.c:175
        filterelt_next = 0x555555eca170
        event = 0x555555f395e0
        loop = EVENT_FILTER_REMOVE
        setup = <optimized out>
        filterelt = <optimized out>
        __func__ = "eventXfwmFilter"
#13 0x00007ffff75bb80f in  () at /usr/lib/
#14 0x00007ffff75bf517 in  () at /usr/lib/
#15 0x00007ffff756315b in gdk_display_get_event () at /usr/lib/
#16 0x00007ffff75bf104 in  () at /usr/lib/
#17 0x00007ffff6f41a84 in g_main_context_dispatch () at /usr/lib/
#18 0x00007ffff6f959b1 in  () at /usr/lib/
#19 0x00007ffff6f40fd3 in g_main_loop_run () at /usr/lib/
#20 0x00007ffff781422f in gtk_main () at /usr/lib/
#21 0x0000555555564e7e in main (argc=<optimized out>, argv=<optimized out>) at main.c:771

xfwm4 has been crashing for me in seemingly random (but only certain) situations a while for me, today I managed to reproduce this with acceptable success rates in Android Studio when viewing/clicking function tooltips. This MR fixes the crash.

I suspect it has to do with a window being destroyed very quickly after appearing.

Merge request reports