Subject: bug#64625: 30.0.50; deleting a focused child frame causes Emacs to ignore all input

From: Andrey Listopadov <[email-masked]>
Date: Sat, 15 Jul 2023 11:28:02 +0300

> Thanks.  Would you please instrument `pgtk_new_focus_frame' (in
> pgtkterm.c) as follows:
>
> diff --git a/src/pgtkterm.c b/src/pgtkterm.c
> index dc2d6477bb5..d62414f4e50 100644
> --- a/src/pgtkterm.c
> +++ b/src/pgtkterm.c
> @@ -4732,6 +4732,9 @@ pgtk_new_focus_frame (struct pgtk_display_info *dpyinfo, struct frame *frame)
>
>    if (frame != dpyinfo->x_focus_frame)
>      {
> +      fprintf (stderr, "pgtk_new_focus_frame: new frame %p, "
> +	       "with outer widget %p\n", (void *) frame,
> +	       (void *) FRAME_GTK_OUTER_WIDGET (frame));
>        /* Set this before calling other routines, so that they see
>           the correct value of x_focus_frame.  */
>        dpyinfo->x_focus_frame = frame;
>
> and show me what is printed when the child frame is initially focused,
> and when you try to focus its parent after it is deleted.

Emacs crashes with the following trace:

pgtk_new_focus_frame: new frame 0x189a888, with outer widget 0x1aaf340
Fatal error 11: Segmentation fault
Backtrace:
emacs(emacs_backtrace+0x3b)[0x56aedb]
emacs(terminate_due_to_signal+0x6f)[0x45e3c5]
emacs[0x45e8c7]
emacs[0x569538]
emacs[0x5695a9]
/lib64/libc.so.6(+0x3db70)[0x7f3d2c4c0b70]
emacs[0x694753]
emacs[0x694d32]
/lib64/libgtk-3.so.0(+0xa1244)[0x7f3d34b60244]
/lib64/libgobject-2.0.so.0(g_closure_invoke+0x14a)[0x7f3d3447e4ea]
/lib64/libgobject-2.0.so.0(+0x42e16)[0x7f3d344ace16]
/lib64/libgobject-2.0.so.0(g_signal_emit_valist+0xb72)[0x7f3d3449d7e2]
/lib64/libgobject-2.0.so.0(g_signal_emit+0x93)[0x7f3d3449df33]
/lib64/libgtk-3.so.0(+0x371174)[0x7f3d34e30174]
/lib64/libgtk-3.so.0(gtk_widget_send_focus_change+0xd4)[0x7f3d34e2e5f4]
/lib64/libgtk-3.so.0(+0x3817c6)[0x7f3d34e407c6]
/lib64/libgtk-3.so.0(+0x381d22)[0x7f3d34e40d22]
/lib64/libgobject-2.0.so.0(g_cclosure_marshal_VOID__OBJECTv+0x77)[0x7f3d3447cf67]
/lib64/libgobject-2.0.so.0(g_signal_emit_valist+0x114a)[0x7f3d3449ddba]
/lib64/libgobject-2.0.so.0(g_signal_emit+0x93)[0x7f3d3449df33]
/lib64/libgobject-2.0.so.0(g_signal_emit_valist+0x114a)[0x7f3d3449ddba]
/lib64/libgobject-2.0.so.0(g_signal_emit+0x93)[0x7f3d3449df33]
/lib64/libgtk-3.so.0(gtk_widget_grab_focus+0x6a)[0x7f3d34e1fb6a]
emacs[0x695ab2]
/lib64/libgtk-3.so.0(+0xa1244)[0x7f3d34b60244]
/lib64/libgobject-2.0.so.0(g_closure_invoke+0x14a)[0x7f3d3447e4ea]
/lib64/libgobject-2.0.so.0(+0x42e16)[0x7f3d344ace16]
/lib64/libgobject-2.0.so.0(g_signal_emit_valist+0xb72)[0x7f3d3449d7e2]
/lib64/libgobject-2.0.so.0(g_signal_emit+0x93)[0x7f3d3449df33]
/lib64/libgtk-3.so.0(+0x371174)[0x7f3d34e30174]
/lib64/libgtk-3.so.0(+0x208580)[0x7f3d34cc7580]
/lib64/libgtk-3.so.0(gtk_main_do_event+0xa3a)[0x7f3d34cc811a]
/lib64/libgdk-3.so.0(+0x3a427)[0x7f3d349fe427]
/lib64/libgdk-3.so.0(+0x72e0e)[0x7f3d34a36e0e]
/lib64/libglib-2.0.so.0(g_main_context_dispatch+0x14c)[0x7f3d3437b39c]
emacs[0x6905b8]
emacs(gobble_input+0xf1)[0x552411]
emacs(unblock_input_to+0x55)[0x552805]
emacs(timer_check+0x98)[0x5533e8]
emacs[0x553975]
emacs[0x553b38]
...

The first ``pgtk_new_focus_frame:'' message is displayed when `emacs -Q'
is started.  Then I've managed to run the make-frame function, but upon
focusing it the crash happens (Emacs also crashes if I focus out.)

--
Andrey Listopadov