I’ve postet this issue to the Sublime Text forum here, but as it it turned out it seems to be caused by GTK.
Whenever the monitor layout changes (insert/remove Notebook into/from docking station), some Sublime Text windows freeze and about the lower third of the frozen window is either black or shows the desktop wallpaper (even if there are other windows behind it). The issue has been there for quite some time and Sublime Text is the only application that shows it.
I have two external screens connected to the notebook (with the notebook screen off), the first one and the notebook have the same resolution, the second screen has a different one. It seems that the problem only occurs when I have a Sublime Text window on this second screen.
Sublime Text 4 (installed from AUR) on Manjaro Linux with KDE Plasma desktop. GTK3 version is 1:3.24.38-1.
Is it indeed caused by a bug in GTK?
Here is a backtrace captured with gdb:
Thread 1 "sublime_text" received signal SIGSEGV, Segmentation fault.
0x00007ffff6326402 in cairo_surface_unmap_image () from /usr/lib/libcairo.so
(gdb) bt
#0 0x00007ffff6326402 in cairo_surface_unmap_image () at /usr/lib/libcairo.so
#1 0x00007ffff5b26a6a in gdk_gl_texture_from_surface (surface=0x7ffff63bc040, region=0x7fffbe24a4a0)
at ../gtk/gdk/gdkgl.c:809
#2 0x00007ffff5b30e5a in gdk_window_end_paint_internal (window=window@entry=0x7fffeee90500)
at ../gtk/gdk/gdkwindow.c:3060
#3 0x00007ffff5b30f77 in gdk_window_end_draw_frame (context=0x7fffd7b5c1f0, window=0x7fffeee90500)
at ../gtk/gdk/gdkwindow.c:3311
#4 gdk_window_end_draw_frame (window=0x7fffeee90500, context=0x7fffd7b5c1f0) at ../gtk/gdk/gdkwindow.c:3294
#5 0x00007ffff515991b in gtk_main_do_event (event=0x7fffffffd1b0) at ../gtk/gtk/gtkmain.c:1844
#6 gtk_main_do_event (event=<optimized out>) at ../gtk/gtk/gtkmain.c:1691
#7 0x00007ffff5b1bb87 in _gdk_event_emit (event=0x7fffffffd1b0) at ../gtk/gdk/gdkevents.c:73
#8 _gdk_event_emit (event=0x7fffffffd1b0) at ../gtk/gdk/gdkevents.c:67
#9 0x00007ffff5b2d982 in _gdk_window_process_updates_recurse_helper
(window=0x7fffeee90500, expose_region=<optimized out>) at ../gtk/gdk/gdkwindow.c:3874
#10 0x00007ffff5b31fd8 in gdk_window_process_updates_internal (window=0x7fffeee90500)
at ../gtk/gdk/gdkwindow.c:4020
#11 0x00007ffff5b321f5 in gdk_window_process_updates_with_mode
(recurse_mode=<optimized out>, window=<optimized out>) at ../gtk/gdk/gdkwindow.c:4215
#12 gdk_window_process_updates_with_mode (window=<optimized out>, recurse_mode=<optimized out>)
at ../gtk/gdk/gdkwindow.c:4186
#13 0x00007ffff7f45b73 in () at /usr/lib/libgobject-2.0.so.0
#14 0x00007ffff7f45c77 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#15 0x00007ffff7f45d34 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#16 0x00007ffff5b28e69 in _gdk_frame_clock_emit_paint (frame_clock=0x7fffef0680f0)
at ../gtk/gdk/gdkframeclock.c:657
#17 gdk_frame_clock_paint_idle (data=0x7fffef0680f0) at ../gtk/gdk/gdkframeclockidle.c:597
#18 0x00007ffff5b156ae in gdk_threads_dispatch (data=0x7fffbe253240) at ../gtk/gdk/gdk.c:769
#19 0x00007ffff7e2139e in () at /usr/lib/libglib-2.0.so.0
#20 0x00007ffff7e1ff19 in () at /usr/lib/libglib-2.0.so.0
#21 0x00007ffff7e7e2b7 in () at /usr/lib/libglib-2.0.so.0
#22 0x00007ffff7e20b47 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#23 0x00007ffff5156f6f in gtk_main () at ../gtk/gtk/gtkmain.c:1329
#24 0x0000555555b1eacb in ()
#25 0x0000555555952d15 in ()
#26 0x00007ffff794ecd0 in __libc_start_call_main
(main=main@entry=0x55555594f61b, argc=argc@entry=3, argv=argv@entry=0x7fffffffe138)
at ../sysdeps/nptl/libc_start_call_main.h:58
#27 0x00007ffff794ed8a in __libc_start_main_impl
(main=0x55555594f61b, argc=3, argv=0x7fffffffe138, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe128) at ../csu/libc-start.c:360
#28 0x00005555558a623a in ()