Subject: bug#62291: 30.0.50; PGTK copy + paste to other app problem

From: Andrew Tropin <[email-masked]>
Date: Fri, 24 Mar 2023 14:39:08 +0400

On 2023-03-24 15:51, Po Lu wrote:

> Andrew Tropin <[email-masked]> writes:
>
>>   preferred_width = 672,
>>   preferred_height = 612,
>>   widget = 0x1014540,
>>   edit_widget = 0x1421130,
>>   vbox_widget = 0x14201c0,
>>   hbox_widget = 0x1420320,
>
> So, the window which is getting this focus in event is 0x1014500, which
> is not any window created by Emacs, assuming that you have only one
> frame.
>
> Perhaps this is a pseudo window created by the GDK Wayland backend to
> ``send'' selection requests to Emacs.
>
> Would you please:
>
>   (gdb) p (GdkWindow *) gtk_widget_get_window ((GtkWidget *) 0x1014500);
>   $NN = ...
>
> and then:
>
>   (gdb) p (GdkWindowType) gdk_window_get_window_type ($NN);
>
> thanks.

I restart the debbugger every time because otherwise my clipboard is
"locked", so the widget from p widget and from output_data.pgtk are the
same.  Sorry for the confusion.

--8<---------------cut here---------------start------------->8---
Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
0x00007ffff71b5424 in signal_emit_unlocked_R.isra.0 () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
(gdb) bt
#0  0x00007ffff71b5424 in signal_emit_unlocked_R.isra.0 () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#1  0x00007ffff71bb21b in g_signal_emit_valist () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#2  0x00007ffff71bb722 in g_signal_emit () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#3  0x00007ffff71a7884 in g_object_dispatch_properties_changed () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#4  0x00007ffff71a9834 in g_object_notify_by_pspec () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#5  0x00007ffff79afbcd in gtk_window_focus_in_event (event=<optimized out>, widget=0x109a500) at gtkwindow.c:8503
#6  gtk_window_focus_in_event (widget=widget@entry=0x109a500, event=<optimized out>) at gtkwindow.c:8491
#7  0x00007ffff79de357 in _gtk_marshal_BOOLEAN__BOXED (closure=0x10b73e0, return_value=0x7fffffffb570, n_param_values=<optimized out>, param_values=0x7fffffffb620, 
    invocation_hint=<optimized out>, marshal_data=<optimized out>) at gtkmarshalers.c:83
#8  0x00007ffff71a34af in g_closure_invoke () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#9  0x00007ffff71b49e9 in signal_emit_unlocked_R.isra.0 () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#10 0x00007ffff71bad65 in g_signal_emit_valist () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#11 0x00007ffff71bb722 in g_signal_emit () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#12 0x00007ffff798ac04 in gtk_widget_event_internal (widget=widget@entry=0x109a500, event=event@entry=0xfbde80) at gtkwidget.c:7808
#13 0x00007ffff798d472 in gtk_widget_event_internal (event=0xfbde80, widget=0x109a500) at gtkwidget.c:7379
#14 0x00007ffff784b37a in gtk_main_do_event (event=0xfbde80) at gtkmain.c:1861
#15 gtk_main_do_event (event=<optimized out>) at gtkmain.c:1691
#16 0x00007ffff7efc3c5 in _gdk_event_emit (event=event@entry=0xfbde80) at gdkevents.c:73
#17 0x00007ffff7f59352 in gdk_event_source_dispatch (base=<optimized out>, callback=<optimized out>, data=<optimized out>) at gdkeventsource.c:124
#18 0x00007ffff70af4cb in g_main_context_dispatch () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libglib-2.0.so.0
#19 0x00000000007771e4 in pgtk_read_socket (terminal=0x1079a00, hold_quit=0x7fffffff
ba10) at pgtkterm.c:3840
#20 0x000000000059703c in gobble_input () at keyboard.c:7424
#21 0x0000000000597580 in handle_async_input () at keyboard.c:7655
#22 0x000000000059759f in process_pending_signals () at keyboard.c:7669
#23 0x00000000005975df in unblock_input_to (level=0) at keyboard.c:7684
#24 0x0000000000597603 in unblock_input () at keyboard.c:7703
#25 0x000000000058fe19 in timer_check () at keyboard.c:4749
#26 0x000000000058ce8a in readable_events (flags=1) at keyboard.c:3531
#27 0x0000000000596f04 in get_input_pending (flags=1) at keyboard.c:7374
#28 0x00000000005a0201 in detect_input_pending_run_timers (do_display=true) at keybo
ard.c:10904
#29 0x00000000006de504 in wait_reading_process_output (time_limit=30, nsecs=0, read_
kbd=-1, do_display=true, wait_for_cell=XIL(0), wait_proc=0x0, just_wait_proc=0)
    at process.c:5779
#30 0x0000000000431ef3 in sit_for (timeout=make_fixnum(30), reading=true, display_op
tion=1) at dispnew.c:6256
#31 0x000000000058a731 in read_char (commandflag=1, map=XIL(0x7ffff41bdb93), prev_ev
ent=XIL(0), used_mouse_menu=0x7fffffffc42f, end_time=0x0) at keyboard.c:2879
#32 0x000000000059e2ee in read_key_sequence (keybuf=0x7fffffffc5c0, prompt=XIL(0), d
ont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, 
    prevent_redisplay=false) at keyboard.c:10081
#33 0x0000000000585bc7 in command_loop_1 () at keyboard.c:1382
#34 0x0000000000667131 in internal_condition_case (bfun=0x5857bc <command_loop_1>, h
andlers=XIL(0x90), hfun=0x584c7f <cmd_error>) at eval.c:1474
#35 0x00000000005853cc in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1131
#36 0x00000000006663ad in internal_catch (tag=XIL(0xff60), func=0x5853a9 <command_lo
op_2>, arg=XIL(0x90)) at eval.c:1197
#37 0x0000000000585365 in command_loop () at keyboard.c:1109
#38 0x000000000058476d in recursive_edit_1 () at keyboard.c:718
#39 0x0000000000584974 in Frecursive_edit () at keyboard.c:801
#40 0x000000000058034c in main (argc=2, argv=0x7fffffffcb08) at emacs.c:2530
(gdb) bt
#0  0x00007ffff71b5424 in signal_emit_unlocked_R.isra.0 () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#1  0x00007ffff71bb21b in g_signal_emit_valist () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#2  0x00007ffff71bb722 in g_signal_emit () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#3  0x00007ffff71a7884 in g_object_dispatch_properties_changed () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#4  0x00007ffff71a9834 in g_object_notify_by_pspec () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#5  0x00007ffff79afbcd in gtk_window_focus_in_event (event=<optimized out>, widget=0x109a500) at gtkwindow.c:8503
#6  gtk_window_focus_in_event (widget=widget@entry=0x109a500, event=<optimized out>) at gtkwindow.c:8491
#7  0x00007ffff79de357 in _gtk_marshal_BOOLEAN__BOXED (closure=0x10b73e0, return_value=0x7fffffffb570, n_param_values=<optimized out>, param_values=0x7fffffffb620, 
    invocation_hint=<optimized out>, marshal_data=<optimized out>) at gtkmarshalers.c:83
#8  0x00007ffff71a34af in g_closure_invoke () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#9  0x00007ffff71b49e9 in signal_emit_unlocked_R.isra.0 () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#10 0x00007ffff71bad65 in g_signal_emit_valist () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#11 0x00007ffff71bb722 in g_signal_emit () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
#12 0x00007ffff798ac04 in gtk_widget_event_internal (widget=widget@entry=0x109a500, event=event@entry=0xfbde80) at gtkwidget.c:7808
#13 0x00007ffff798d472 in gtk_widget_event_internal (event=0xfbde80, widget=0x109a500) at gtkwidget.c:7379
#14 0x00007ffff784b37a in gtk_main_do_event (event=0xfbde80) at gtkmain.c:1861
#15 gtk_main_do_event (event=<optimized out>) at gtkmain.c:1691
#16 0x00007ffff7efc3c5 in _gdk_event_emit (event=event@entry=0xfbde80) at gdkevents.c:73
#17 0x00007ffff7f59352 in gdk_event_source_dispatch (base=<optimized out>, callback=<optimized out>, data=<optimized out>) at gdkeventsource.c:124
#18 0x00007ffff70af4cb in g_main_context_dispatch () from /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libglib-2.0.so.0
#19 0x00000000007771e4 in pgtk_read_socket (terminal=0x1079a00, hold_quit=0x7fffffffba10) at pgtkterm.c:3840
#20 0x000000000059703c in gobble_input () at keyboard.c:7424
#21 0x0000000000597580 in handle_async_input () at keyboard.c:7655
#22 0x000000000059759f in process_pending_signals () at keyboard.c:7669
#23 0x00000000005975df in unblock_input_to (level=0) at keyboard.c:7684
#24 0x0000000000597603 in unblock_input () at keyboard.c:7703
#25 0x000000000058fe19 in timer_check () at keyboard.c:4749
#26 0x000000000058ce8a in readable_events (flags=1) at keyboard.c:3531
#27 0x0000000000596f04 in get_input_pending (flags=1) at keyboard.c:7374
#28 0x00000000005a0201 in detect_input_pending_run_timers (do_display=true) at keyboard.c:10904
#29 0x00000000006de504 in wait_reading_process_output (time_limit=30, nsecs=0, read_kbd=-1, do_display=true, wait_for_cell=XIL(0), wait_proc=0x0, just_wait_proc=0)
    at process.c:5779
--Type <RET> for more, q to quit, c to continue without paging--c
#30 0x0000000000431ef3 in sit_for (timeout=make_fixnum(30), reading=true, display_option=1) at dispnew.c:6256
#31 0x000000000058a731 in read_char (commandflag=1, map=XIL(0x7ffff41bdb93), prev_event=XIL(0), used_mouse_menu=0x7fffffffc42f, end_time=0x0) at keyboard.c:2879
#32 0x000000000059e2ee in read_key_sequence (keybuf=0x7fffffffc5c0, prompt=XIL(0), dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false) at keyboard.c:10081
#33 0x0000000000585bc7 in command_loop_1 () at keyboard.c:1382
#34 0x0000000000667131 in internal_condition_case (bfun=0x5857bc <command_loop_1>, handlers=XIL(0x90), hfun=0x584c7f <cmd_error>) at eval.c:1474
#35 0x00000000005853cc in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1131
#36 0x00000000006663ad in internal_catch (tag=XIL(0xff60), func=0x5853a9 <command_loop_2>, arg=XIL(0x90)) at eval.c:1197
#37 0x0000000000585365 in command_loop () at keyboard.c:1109
#38 0x000000000058476d in recursive_edit_1 () at keyboard.c:718
#39 0x0000000000584974 in Frecursive_edit () at keyboard.c:801
#40 0x000000000058034c in main (argc=2, argv=0x7fffffffcb08) at emacs.c:2530
(gdb) frame 12
#12 0x00007ffff798ac04 in gtk_widget_event_internal (widget=widget@entry=0x109a500, event=event@entry=0xfbde80) at gtkwidget.c:7808
7808    gtkwidget.c: No such file or directory.
(gdb) p widget
$1 = (GtkWidget *) 0x109a500
(gdb) p Vframe_list 
$2 = XIL(0x7ffff41d3203)
(gdb) xcar
$3 = XIL(0x1079c2d)
(gdb) xframe
$4 = (struct frame *) 0x1079c28
"*scratch* - GNU Emacs at ixy"
(gdb) p *$4->output_data.pgtk
$5 = {
  foreground_color = 0,
  background_color = 16777215,
  toolbar = 0x0,
  last_user_time = 0,
  current_cursor = 0x1230860,
  text_cursor = 0x12a36a0,
  nontext_cursor = 0x1230860,
  modeline_cursor = 0x12a36a0,
  hand_cursor = 0x0,
  hourglass_cursor = 0x12a3760,
  horizontal_drag_cursor = 0x0,
  vertical_drag_cursor = 0x0,
  left_edge_cursor = 0x12a3700,
  top_left_corner_cursor = 0x12a3580,
  top_edge_cursor = 0x12a3860,
  top_right_corner_cursor = 0x1273760,
  right_edge_cursor = 0x12a3800,
  bottom_right_corner_cursor = 0x12a35e0,
  bottom_edge_cursor = 0x12a3460,
  bottom_left_corner_cursor = 0x12a3520,
  current_pointer = 0x0,
  border_pixel = 0,
  border_color_css_provider = 0x19a3500,
  scrollbar_foreground_css_provider = 0x1273440,
  scrollbar_background_css_provider = 0x1253440,
  hourglass_widget = 0x0,
  cursor_xgcv = {
    foreground = 16777215,
    background = 0
  },
  window_desc = 0,
--Type <RET> for more, q to quit, c to continue without paging--c
  parent_desc = 42,
  explicit_parent = 0 '\000',
  icon_bitmap = 0,
  font = 0x138eb38,
  baseline_offset = 0,
  fontset = 2,
  mouse_color = 0,
  cursor_color = 0,
  cursor_foreground_color = 16777215,
  icon_top = 0,
  icon_left = 0,
  vertical_scroll_bar_extra = 0,
  titlebar_height = 0,
  toolbar_height = 0,
  display_info = 0x12a3000,
  zooming = 0,
  in_animation = 0,
  size_hints = {
    min_width = 0,
    min_height = 0,
    max_width = 0,
    max_height = 0,
    base_width = 0,
    base_height = 0,
    width_inc = 0,
    height_inc = 0,
    min_aspect = 0,
    max_aspect = 0,
    win_gravity = 0
  },
  hint_flags = 0,
  preferred_width = 672,
  preferred_height = 612,
  widget = 0x109a500,
  edit_widget = 0x141f130,
  vbox_widget = 0x141e1c0,
  hbox_widget = 0x141e320,
  menubar_widget = 0x146b1a0,
  toolbar_widget = 0x1420260,
  toolbar_in_hbox = false,
  toolbar_is_packed = true,
  ttip_widget = 0x0,
  ttip_lbl = 0x0,
  ttip_window = 0x0,
  menubar_height = 25,
  toolbar_top_height = 41,
  toolbar_bottom_height = 0,
  toolbar_left_width = 0,
  toolbar_right_width = 0,
  cr_context = 0x14255e0,
  cr_active = 0x14255e0,
  cr_surface_desired_width = 624,
  cr_surface_desired_height = 604,
  cr_surface_visible_bell = 0x0,
  atimer_visible_bell = 0x0,
  has_been_visible = 1,
  black_relief = {
    xgcv = {
      foreground = 7566195,
      background = 7779407
    },
    pixel = 7566195
  },
  white_relief = {
    xgcv = {
      foreground = 15132390,
      background = 7779407
    },
    pixel = 15132390
  },
  relief_background = 12566463,
  relief_background_valid_p = true,
  focus_state = 0,
  watched_scale_factor = 2,
  scale_factor_atimer = 0x104ecd0
}
(gdb) p (gdkWindow *) gtk_widget_get_window ((GtkWidget *) 0x109a500)
No symbol "gdkWindow" in current context.
(gdb) p (GdkWindow *) gtk_widget_get_window ((GtkWidget *) 0x109a500)
$6 = (GdkWindow *) 0x107e450
(gdb) p (GdkWindowType) gdk_window_get_window_type ($6)
$7 = GDK_WINDOW_TOPLEVEL
(gdb) 
--8<---------------cut here---------------end--------------->8---

Additional info about the actions I do:

run emacs -Q
copy text from scratch buffer
try to insert in chromium address bar
C-g on frozen emacs
Try to toggle full screen frozen chromium
Emacs usually crashes with seg fault we are exploring right now

It seems there are some timeouts involved, because it reproduces from
time to time: sometimes it unfreezes both chromium and emacs without
crash (at least immediate crash), sometimes it crashes differently (can
show logs if you want).

-- 
Best regards,
Andrew Tropin