Subject: bug#50322: closed (Re: bug#50322: 28.0.50; feature/pgtk: segfault in pgtk_mouse_position)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 21 Nov 2021 15:05:02 +0000

Your bug report

#50322: 28.0.50; feature/pgtk: segfault in pgtk_mouse_position

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
50322: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=50322
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#50322: 28.0.50; feature/pgtk: segfault in pgtk_mouse_position
From: Yuuki Harano <[email-masked]>
To: [email-masked]
Date: Mon, 22 Nov 2021 00:04:23 +0900 (JST)
List-Id: <debbugs-submit.debbugs.gnu.org>

Subject: 28.0.50; feature/pgtk: segfault in pgtk_mouse_position
From: Henri Menke <[email-masked]>
To: [email-masked]
Date: Wed, 01 Sep 2021 09:32:49 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

When enabling `xterm-mouse-mode` mouse click events can also come from
non-graphical frames. This works fine, when there are only non-
graphical frames, but as soon as there is a graphical frame *and* a
non-graphical frame, mouse events in the non-graphical frame crash
Emacs.

Steps to reproduce:

1. Start Emacs daemon

   $ emacs -Q --fg-daemon --eval '(xterm-mouse-mode t)'

2. Start two frames, one graphical, one non-graphical

   $ emacsclient -c &
   $ emacsclient -c -t

3. Click around in both frames to provoke the crash.

The problem is that `pgtk_mouse_position` calls `gtk_widget_get_window`
even for mouse events that do not come from a GTK frame.

#0  0x00007ffff7b58819 in gtk_widget_get_window () from /nix/store/y3c2q2c3p33qg1lnqpivji842mzd39n4-gtk+3-3.24.27/lib/libgtk-3.so.0
#1  0x00000000005c4d2d in pgtk_mouse_position (fp=0x7fffffff2580, insist=<optimized out>, bar_window=0x7fffffff2588, part=0x7fffffff257c, x=<optimized out>, y=<optimized out>, timestamp=<optimized out>) at pgtkterm.c:3354
#2  0x00000000004e8e00 in kbd_buffer_get_event (kbp=kbp@entry=0x7fffffff25e8, used_mouse_menu=used_mouse_menu@entry=0x7fffffff2b2b, end_time=end_time@entry=0x0) at keyboard.c:4087
#3  0x00000000004e8fce in read_event_from_main_queue (end_time=end_time@entry=0x0, local_getcjmp=local_getcjmp@entry=0x7fffffff28b0, used_mouse_menu=used_mouse_menu@entry=0x7fffffff2b2b) at keyboard.c:2180
#4  0x00000000004e9283 in read_decoded_event_from_main_queue (end_time=end_time@entry=0x0, local_getcjmp=local_getcjmp@entry=0x7fffffff28b0, prev_event=prev_event@entry=0x0, used_mouse_menu=used_mouse_menu@entry=0x7fffffff2b2b) at keyboard.c:2243
#5  0x00000000004ea4d4 in read_char (commandflag=1, map=map@entry=0x191c1c3, prev_event=0x0, used_mouse_menu=used_mouse_menu@entry=0x7fffffff2b2b, end_time=end_time@entry=0x0) at keyboard.c:2874
#6  0x00000000004ebb52 in read_key_sequence (keybuf=keybuf@entry=0x7fffffff2c00, prompt=prompt@entry=0x0, dont_downcase_last=dont_downcase_last@entry=false, can_return_switch_frame=can_return_switch_frame@entry=true, fix_current_buffer=fix_current_buffer@entry=true, prevent_redisplay=prevent_redisplay@entry=false) at keyboard.c:9575
#7  0x00000000004ec776 in command_loop_1 () at lisp.h:1002
#8  0x0000000000557d93 in internal_condition_case (bfun=bfun@entry=0x4ec514 <command_loop_1>, handlers=handlers@entry=0x90, hfun=hfun@entry=0x4e244d <cmd_error>) at eval.c:1478
#9  0x00000000004dd815 in command_loop_2 (handlers=handlers@entry=0x90) at keyboard.c:1115
#10 0x000000000055a0e0 in internal_catch (tag=tag@entry=0xe6d0, func=func@entry=0x4dd7fb <command_loop_2>, arg=arg@entry=0x90) at eval.c:1198
#11 0x00000000004dd7d7 in command_loop () at lisp.h:1002
#12 0x00000000004e2063 in recursive_edit_1 () at keyboard.c:720
#13 0x00000000004e237a in Frecursive_edit () at keyboard.c:792
#14 0x00000000004dcee2 in main (argc=5, argv=0x7fffffff2f88) at emacs.c:2325

Full backtrace in attachment gdb.log.

Some stuff shows as `<optimized out>` unfortunately, even though I
configured Emacs with `-Og -ggdb3`. Looks like there are some
optimization options creeping in from elsewhere.

;;===================
In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.16.0)
Repository revision: 74d017edb6717ad76d38edc02ad3210d4ad66b96
Repository branch: nixos-21.05
Windowing system distributor 'System Description: NixOS 21.05 (Okapi)

Configured using:
 'configure
 --prefix=/nix/store/p2yxdx48mqgvaflygysqz5b7p7q2bbpw-emacs-pgtkgcc-20210725.0
 --disable-build-details --with-modules --with-x-toolkit=gtk3
 --with-cairo --with-native-compilation --with-pgtk'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix