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: Fri, 29 Mar 2024 21:05:50 +0300

> Date: Fri, 29 Mar 2024 15:52:12 +0100 (CET)
> From:  "Abraham S.A.H." via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> ## System Information:
> 
> * Kernel: 6.8.2-2
> * DE: Gnome 46.0
> * WM: Mutter (Wayland)
> * gnome-shell: 46.0
> * wayland: 1.22.0
> * mutter: 46.0
> * wl-clipboard: 2.2.1
> * weston: 13.0.0
> * sway: 1.9-e93da93
> * emacs package: emacs-wayland 29.3-1.1 (archlinux)
> 
> ## Steps to reproduce the issue under Gnome:
> 
> 1. Invoke `emacs -Q` in any terminal emulator to start Emacs along with
>    its GUI frame.
> 2. Mark/highlight some area of text with your mouse pointer. OR use
>    C-Space and keyboard movement shortcuts to do the same.
> 3. Open any other application. (gnome-text-editor, for example)
> 4. Use your middle mouse button in an editable text area of the second
>    application's frame.
> 5. Emacs crashes.
> 
> NOTE1: Emacs doesn't crash if you just middle click in any 
>        *non-textual/non-editable* area, outside Emacs.
> NOTE2: Middle clicking *inside* any of Emacs' own buffers DOES work
>        properly without any crash or noticeable problem.
> NOTE3: The problem is reproducible both when marking with mouse cursor
>        or when marking with keyboard shortcuts.
> NOTE4: Using another shortcut that pastes the Primary selection of the
>        wayland, instead of mouse's middle click, also reproduces the 
>        same issue. E.g. S-Insert of WezTerm.
> NOTE5: Marking a text outside of Emacs and middle clicking inside
>        Emacs works flawlessly.

Is this different from bug#70072 that you submitted a few minutes ago,
or is this the same problem?  It sounds almost the same problem, just
triggered in 2 different ways.

> 
> ## State of the issue under Sway:
> 
> The issue is completely reproducable under sway with the same steps as
> above, with the same symptoms and the same segmentation fault error.
> 
> ## State of the issue under Weston:
> 
> The issue is not reproducable under Weston but the functionality is
> also lost.  Weston doesn't support primary selection.
> 
> ## Tried Workarounds:
> 
> ### Workaround number 1:
> Disable the primary selection.  In gnome you can disable 
> primary selection.  Brings users to the same state of under 
> Weston.  Emacs will not crash, Primary selection works inside 
> Emacs, but not outside of Emacs.
> 
> Emacs still crashes if user uses the middle click inside applications
> that try to pull primary selection with middle click.
> 
> ### Workaround number 2:
> Set variable `select-active-regions` to `nil`.	Disables the
> functionality and of course removes the issue.
> 
> ## Terminal log of Emacs after crash:
> 
> ~~~~~~~ Start of the terminal log
> 
> Fatal error 11: Segmentation fault
> Backtrace:
> emacs(+0x16bc62)[0x5f8b0fcddc62]
> emacs(+0x20243)[0x5f8b0fb92243]
> emacs(+0x21d44)[0x5f8b0fb93d44]
> /usr/lib/libc.so.6(+0x41b30)[0x735b53041b30]

Thank you for your report, but these backtraces can only be
interpreted on your system.  So either convert them to human-readable
lists of file names, line numbers, and function names as described in
the node "Crashing" of the Emacs user manual, or run Emacs from GDB,
and when Emacs crashes, type "bt" at the GDB prompt and post the
backtrace produced by GDB.