Bug #2499
opengtk4: Detached tab is never freed
0%
Description
Double-click the "Diplomacy [1]" tab label to detach it into a window, then close the window with its close button. When the server's cancel comes back:
GLib-GObject: invalid unclassed pointer in cast to 'GtkWindow'
Gtk: gtk_window_destroy: assertion 'GTK_IS_WINDOW (window)' failed
and later, on disconnect, gui_dialog_destroy_all() writes into the already freed dipl_main (heap-use-after-free under ASan).
gui_dialog_detach() takes a reference on dlg->grid so gtk_notebook_remove_page() won't destroy it, and never drops it. When the window is destroyed the grid survives, so gui_dialog_destroy_handler() never runs: the gui_dialog and the whole tab content leak, the dialog stays in dialog_list, and its v.window and source point at things that are gone. This happens to any detached tab, not only diplomacy.
Attached patch drops the reference once the window holds the grid.
Depends on #2498 ; without it, closing the window would then free the dialog behind diplomacy's back.
Files