Subject: bug#70073: 29.3; Emacs-PGTK crashes upon marking some text inside emacs and then middle clicking outside of Emacs

From: Eli Zaretskii <[email-masked]>
Date: Thu, 02 May 2024 11:42:44 +0300

> Date: Sun, 21 Apr 2024 01:18:22 +0200 (CEST)
> From: "Abraham S.A.H." <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>, 70073 <[email-masked]>
> 
> Hello;
> 
> I have wiped out everything of my system and installed just Xfce4 
> and sway (for testing Emacs PGTK).
> 
> By wiping out, I mean formatting my entire disk, then repartitioning and
> reinstallation of my new desktops and neccessary applications.
> 
> The problem still persists. I include the result of 
> report-emacs-bug with this new system with this email.
> 
> One reason for me replying late is that I have to uninstall emacs-lucid 
> and reinstall emacs-wayland and switch to a wayland desktop, each time 
> that I want to test it. However, this time I was also busy with some other
> works. 
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/usr/lib/libthread_db.so.1".
> [New Thread 0x7fffeda006c0 (LWP 12909)]
> [New Thread 0x7fffe7e006c0 (LWP 12910)]
> [New Thread 0x7fffed0006c0 (LWP 12911)]
> [New Thread 0x7fffe74006c0 (LWP 12912)]
> [New Thread 0x7fffe6a006c0 (LWP 12913)]
> [Detaching after vfork from child process 12932]
> 
> Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
> pgtk_handle_selection_request (event=0x7fffffffba80) at /usr/src/debug/emacs/emacs-29.3-wayland/src/pgtkselect.c:573
> warning: 573    /usr/src/debug/emacs/emacs-29.3-wayland/src/pgtkselect.c: No such file or directory
> (gdb) thread apply all bt
> [...]
> Thread 1 (Thread 0x7ffff20db080 (LWP 12897) "emacs"):
> #0  pgtk_handle_selection_request (event=0x7fffffffba80) at /usr/src/debug/emacs/emacs-29.3-wayland/src/pgtkselect.c:573
> #1  0x00005555556fbc8d in pgtk_handle_selection_event (event=0x7fffffffba80) at /usr/src/debug/emacs/emacs-29.3-wayland/src/pgtkselect.c:784
> #2  process_special_events () at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:4449
> #3  0x00005555556fcd91 in swallow_events (do_display=true) at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:4489
> #4  0x0000555555831607 in wait_reading_process_output (time_limit=<optimized out>, nsecs=<optimized out>, read_kbd=<optimized out>, do_display=<optimized out>, wait_for_cell=<optimized out>, wait_proc=<optimized out>, just_wait_proc=<optimized out>) at /usr/src/debug/emacs/emacs-29.3-wayland/src/process.c:5788
> #5  0x00005555555eea46 in sit_for (timeout=<optimized out>, reading=<optimized out>, display_option=<optimized out>) at /usr/src/debug/emacs/emacs-29.3-wayland/src/dispnew.c:6264
> #6  0x0000555555705551 in read_char (commandflag=1, map=0x555556e5e753, prev_event=0x0, used_mouse_menu=0x7fffffffc5ab, end_time=0x0) at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:2881
> #7  0x00005555558d7de7 in read_key_sequence.constprop.0 (keybuf=<optimized out>, prevent_redisplay=false, fix_current_buffer=<optimized out>, can_return_switch_frame=<optimized out>, dont_downcase_last=<optimized out>, prompt=<optimized out>) at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:10084
> #8  0x00005555556f50f4 in command_loop_1 () at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:1384
> #9  0x00005555557b50df in internal_condition_case (bfun=0x5555556f4e20 <command_loop_1>, handlers=<optimized out>, hfun=0x5555556f2890 <cmd_error>) at /usr/src/debug/emacs/emacs-29.3-wayland/src/eval.c:1474
> #10 0x00005555556f2b6e in command_loop_2 (handlers=handlers@entry=0x90) at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:1133
> #11 0x00005555557b5035 in internal_catch (tag=<optimized out>, func=0x5555556f2b40 <command_loop_2>, arg=0x90) at /usr/src/debug/emacs/emacs-29.3-wayland/src/eval.c:1197
> #12 0x00005555556f48f9 in command_loop () at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:1111
> #13 0x000055555590ceb0 in recursive_edit_1.isra.0 () at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:720
> #14 0x00005555556f4e00 in Frecursive_edit () at /usr/src/debug/emacs/emacs-29.3-wayland/src/keyboard.c:803
> #15 0x00005555556fa777 in main (argc=<optimized out>, argv=0x7fffffffccb8) at /usr/src/debug/emacs/emacs-29.3-wayland/src/emacs.c:2521
> (gdb) p *(struct selection_input_event *) event
> $1 = {kind = SELECTION_REQUEST_EVENT, dpyinfo = 0x56267e20, requestor = 0x5555563c4330, selection = 0x1, target = 0x4d, property = 0x5e, time = 0}
> (gdb) p *$1->dpyinfo
> Cannot access memory at address 0x56267e20
> (gdb) p *$1->requestor
> $2 = <incomplete type>
> (gdb) k
> Kill the program being debugged? (y or n) y                                                                                                                   [Inferior 1 (process 12897) killed]
> (gdb) q

Po Lu, any suggestions for how to move forward with this issue?