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.
Start two frames, one graphical, one non-graphical
$ emacsclient -c &
$ emacsclient -c -t
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
Some stuff shows as `` unfortunately, even though I configured Emacs with `-Og -ggdb3`. Looks like there are some optimization options creeping in from elsewhere.
```c
Thread 5 (Thread 0x7fffe2c8c640 (LWP 282960) "dconf worker"):
#0 0x00007ffff5b9b329 in poll () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff70e07ee in g_main_context_iterate.constprop () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#2 0x00007ffff70e090f in g_main_context_iteration () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#3 0x00007fffe2ca456d in dconf_gdbus_worker_thread () from /nix/store/6px5h5v8j2lphnkafk8ysc69xh0s757x-dconf-0.40.0-lib/lib/gio/modules/libdconfsettings.so
No symbol table info available.
#4 0x00007ffff710a28d in g_thread_proxy () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#5 0x00007ffff5dfde9e in start_thread () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0
No symbol table info available.
#6 0x00007ffff5ba549f in clone () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
Thread 4 (Thread 0x7fffe34ac640 (LWP 282959) "gdbus"):
#0 0x00007ffff5b9b329 in poll () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff70e07ee in g_main_context_iterate.constprop () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#2 0x00007ffff70e0b4b in g_main_loop_run () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#3 0x00007ffff7334d56 in gdbus_shared_thread_func () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libgio-2.0.so.0
No symbol table info available.
#4 0x00007ffff710a28d in g_thread_proxy () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#5 0x00007ffff5dfde9e in start_thread () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0
No symbol table info available.
#6 0x00007ffff5ba549f in clone () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
Thread 3 (Thread 0x7fffe3cb8640 (LWP 282958) "pool-emacs"):
#0 0x00007ffff5ba0299 in syscall () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff71338c2 in g_cond_wait_until () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#2 0x00007ffff70af621 in g_async_queue_pop_intern_unlocked () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#3 0x00007ffff70afc42 in g_async_queue_timeout_pop () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#4 0x00007ffff710abf9 in g_thread_pool_thread_proxy () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#5 0x00007ffff710a28d in g_thread_proxy () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#6 0x00007ffff5dfde9e in start_thread () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0
No symbol table info available.
#7 0x00007ffff5ba549f in clone () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
Thread 2 (Thread 0x7fffe4585640 (LWP 282914) "gmain"):
#0 0x00007ffff5b9b329 in poll () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff70e07ee in g_main_context_iterate.constprop () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#2 0x00007ffff70e090f in g_main_context_iteration () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#3 0x00007ffff70e0961 in glib_worker_main () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#4 0x00007ffff710a28d in g_thread_proxy () from /nix/store/9jvzb0zwl093dwj3i12ls068k4dv911z-glib-2.68.2/lib/libglib-2.0.so.0
No symbol table info available.
#5 0x00007ffff5dfde9e in start_thread () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libpthread.so.0
No symbol table info available.
#6 0x00007ffff5ba549f in clone () from /nix/store/gk42f59363p82rg2wv2mfy71jn5w4q4c-glibc-2.32-48/lib/libc.so.6
No symbol table info available.
Thread 1 (Thread 0x7ffff26f44c0 (LWP 282910) "emacs"):
#0 0x00007ffff7b58811 in gtk_widget_get_window () from /nix/store/y3c2q2c3p33qg1lnqpivji842mzd39n4-gtk+3-3.24.27/lib/libgtk-3.so.0
No symbol table info available.
#1 0x00000000005c4d2d in pgtk_mouse_position (fp=0x7fffffff2580, insist=, bar_window=0x7fffffff2588, part=0x7fffffff257c, x=, y=, timestamp=) at pgtkterm.c:3354
f1 = 0xbe0ee8
dpyinfo =
win_x = 23
win_y = 431
seat =
device =
mask = 0
win =
frame =
tail =
gdpy =
#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
bar_window = 0xf59f511204878000
y = 0x2
f = 0xdbe2e0
part = scroll_bar_nowhere
x = 0x0
t = 10536992
obj =
#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
c = 0x0
save_jump = {{
__jmpbuf = {0, 0, 0, 0, 0, 0, 0, 0},
__mask_was_saved = 0,
__saved_mask = {
__val = {0 }
}
}}
kb = 0xb62270
count = 3
#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
nextevt =
frame =
terminal =
events = {0x610fcc90, 0x138a65a1, 0x0, 0x19222b3, 0x0, 0x1dcd6500, 0xbe0eed, 0xf59f511204878000, 0x12, 0x0, 0x18dbb33, 0x0, 0x1, 0xbe0eed, 0x1, 0x4e4030 }
n = 0
#5 0x00000000004ea4d4 in read_char (commandflag=1, map=map@entry=0x1922233, prev_event=0x0, used_mouse_menu=used_mouse_menu@entry=0x7fffffff2b2b, end_time=end_time@entry=0x0) at keyboard.c:2874
c =
jmpcount = 3
local_getcjmp = {{
__jmpbuf = {1, -5891606050207377119, 93, 11936368, 12455661, 0, 5891606700418062625, -5891607200639952607},
__mask_was_saved = 0,
__saved_mask = {
__val = {1118, 11838781, 5537219, 34128, 140737488300400, 2, 0, 10615312, 5599801, 279, 3, 0, 140737250702248, 140737257185451, 5536066, 140737257185435}
}
}}
save_jump = {{
__jmpbuf = {0, 0, 0, 0, 0, 0, 0, 0},
__mask_was_saved = 0,
__saved_mask = {
__val = {0 }
}
}}
tem =
save =
previous_echo_area_message = 0x0
also_record = 0x0
reread = false
recorded = false
polling_stopped_here = true
orig_kboard = 0xb62270
#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
interrupted_kboard = 0xb62270
interrupted_frame = 0xbe0ee8
key =
used_mouse_menu = false
echo_local_start = 0
last_real_key_start = 0
keys_local_start =
new_binding =
count = 3
t = 0
echo_start = 0
keys_start = 0
current_binding = 0x1922233
first_unbound = 31
mock_input = 0
used_mouse_menu_history = {false }
fkey = {
parent = 0xbbdc93,
map = 0xbbdc93,
start = 0,
end = 0
}
keytran = {
parent = 0x7ffff23824cb,
map = 0x7ffff23824cb,
start = 0,
end = 0
}
indec = {
parent = 0xbbdc83,
map = 0xbbdc83,
start = 0,
end = 0
}
shift_translated = false
delayed_switch_frame = 0x0
original_uppercase = 0x0
original_uppercase_position = -1
dummyflag = false
starting_buffer = 0xb4a538
fake_prefixed_keys = 0x0
first_event = 0x0
second_event =
#7 0x00000000004ec776 in command_loop_1 () at lisp.h:1002
cmd =
keybuf = {0x19238b3, 0x16e, 0xf2, 0x8a00, 0xa1fec0 , 0x0, 0x2, 0xfa2, 0xffffffff, 0x547dc3 , 0x8a00, 0x7fffffff2cb0, 0x2, 0x0, 0xa1fec0 , 0x557239 , 0xac7110, 0x3, 0xacaa43, 0x0, 0x0, 0x55874f , 0xa, 0x8a00, 0x0, 0x7ffff1ccc70d, 0x0, 0xf59f511204878000, 0x3, 0x7ffff238920b}
i =
prev_modiff = 93
prev_buffer = 0xb4a538
already_adjusted = false
#8 0x0000000000557d93 in internal_condition_case (bfun=bfun@entry=0x4ec514 , handlers=handlers@entry=0x90, hfun=hfun@entry=0x4e244d ) at eval.c:1478
val = 0xe165a0
c = 0xb61b10
#9 0x00000000004dd815 in command_loop_2 (handlers=handlers@entry=0x90) at keyboard.c:1115
val = 0xe165a0
#10 0x000000000055a0e0 in internal_catch (tag=tag@entry=0xe6d0, func=func@entry=0x4dd7fb , arg=arg@entry=0x90) at eval.c:1198
val =
c = 0xb42a00
#11 0x00000000004dd7d7 in command_loop () at lisp.h:1002
No locals.
#12 0x00000000004e2063 in recursive_edit_1 () at keyboard.c:720
count = 1
val =
#13 0x00000000004e237a in Frecursive_edit () at keyboard.c:792
count = 0
buffer =
#14 0x00000000004dcee2 in main (argc=5, argv=0x7fffffff2f88) at emacs.c:2325
stack_bottom_variable = 0x756e6547fffffab0
no_loadup = false
junk = 0x0
dname_arg = 0x0
ch_to_dir = 0x0
original_pwd =
dump_mode =
skip_args = 1
temacs = 0x0
attempt_load_pdump =
rlim = {
rlim_cur = 10022912,
rlim_max = 18446744073709551615
}
lc_all =
sockfd = -1
module_assertions =
```
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:
The problem is that
pgtk_mouse_position
callsgtk_widget_get_window
even for mouse events that do not come from a GTK frame.Full backtrace
Some stuff shows as `