Subject: bug#47334: 27.1; Incompatibility between daemon, desktop and highlight-changes-mode

From: Gilles <[email-masked]>
Date: Sun, 28 Mar 2021 16:25:08 +0200

I did include the Lisp backtrace: it's empty.

I used src/.gdbinit from the Emacs source tree. Here's the output I get from
    gdb -batch -ex bt -ex xbacktrace ./emacs 1409856
at an idle "emacs -Q":

[New LWP 1409857]
[New LWP 1409858]
[New LWP 1409859]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f696c484246 in __pselect (nfds=9, readfds=0x7ffdf9113730,
writefds=0x7ffdf91137b0, exceptfds=0x0, timeout=<optimized out>,
sigmask=<optimized out>) at ../sysdeps/unix/sysv/linux/pselect.c:48
48      ../sysdeps/unix/sysv/linux/pselect.c: No such file or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not
from terminal]
DISPLAY = :0
TERM = xterm
Breakpoint 1 at 0x55e20e9cddbd: file emacs.c, line 379.
Breakpoint 2 at 0x55e20e97f6f6: file xterm.c, line 10145.
#0  0x00007f696c484246 in __pselect (nfds=9, readfds=0x7ffdf9113730,
writefds=0x7ffdf91137b0, exceptfds=0x0, timeout=<optimized out>,
sigmask=<optimized out>) at ../sysdeps/unix/sysv/linux/pselect.c:48
#1  0x000055e20ec8afbe in really_call_select (arg=0x7ffdf9113620) at
thread.c:586
#2  0x000055e20eaf10ff in flush_stack_call_func (func=0x55e20ec8aef3
<really_call_select>, arg=0x7ffdf9113620) at alloc.c:4951
#3  0x000055e20ec8b0ba in thread_select (func=0x7f696c484180
<__pselect>, max_fds=9, rfds=0x7ffdf9113730, wfds=0x7ffdf91137b0,
efds=0x0, timeout=0x7ffdf9113d60, sigmask=0x0) at thread.c:616
#4  0x000055e20ecf3770 in xg_select (fds_lim=9, rfds=0x7ffdf9113dd0,
wfds=0x7ffdf9113e50, efds=0x0, timeout=0x7ffdf9113d60, sigmask=0x0) at
xgselect.c:117
#5  0x000055e20ebfcc7c in wait_reading_process_output (time_limit=0,
nsecs=0, read_kbd=-1, do_display=true, wait_for_cell=XIL(0),
wait_proc=0x0, just_wait_proc=0) at process.c:5572
#6  0x000055e20e9e4260 in kbd_buffer_get_event (kbp=0x7ffdf9114130,
used_mouse_menu=0x7ffdf9114735, end_time=0x0) at keyboard.c:3866
#7  0x000055e20e9de89d in read_event_from_main_queue (end_time=0x0,
local_getcjmp=0x7ffdf9114540, used_mouse_menu=0x7ffdf9114735) at
keyboard.c:2156
#8  0x000055e20e9decb3 in read_decoded_event_from_main_queue
(end_time=0x0, local_getcjmp=0x7ffdf9114540, prev_event=XIL(0),
used_mouse_menu=0x7ffdf9114735) at keyboard.c:2220
#9  0x000055e20e9e1030 in read_char (commandflag=1,
map=XIL(0x55e210c8daa3), prev_event=XIL(0),
used_mouse_menu=0x7ffdf9114735, end_time=0x0) at keyboard.c:2830
#10 0x000055e20e9f373b in read_key_sequence (keybuf=0x7ffdf9114920,
prompt=XIL(0), dont_downcase_last=false, can_return_switch_frame=true,
fix_current_buffer=true, prevent_redisplay=false) at keyboard.c:9554
#11 0x000055e20e9dbf70 in command_loop_1 () at keyboard.c:1350
#12 0x000055e20eb53339 in internal_condition_case (bfun=0x55e20e9dbad2
<command_loop_1>, handlers=XIL(0x90), hfun=0x55e20e9db082 <cmd_error>)
at eval.c:1356
#13 0x000055e20e9db693 in command_loop_2 (ignore=XIL(0)) at keyboard.c:1091
#14 0x000055e20eb5271c in internal_catch (tag=XIL(0xcc60),
func=0x55e20e9db662 <command_loop_2>, arg=XIL(0)) at eval.c:1117
#15 0x000055e20e9db62d in command_loop () at keyboard.c:1070
#16 0x000055e20e9dab49 in recursive_edit_1 () at keyboard.c:714
#17 0x000055e20e9dad49 in Frecursive_edit () at keyboard.c:786
#18 0x000055e20e9d075d in main (argc=2, argv=0x7ffdf9114da8) at emacs.c:2067
[Inferior 1 (process 1409856) detached]

And after pressing C-x C-f in that Emacs instance so that it's showing
the find-file prompt:

[New LWP 1409857]
[New LWP 1409858]
[New LWP 1409859]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f696c484246 in __pselect (nfds=9, readfds=0x7ffdf9111050,
writefds=0x7ffdf91110d0, exceptfds=0x0, timeout=<optimized out>,
sigmask=<optimized out>) at ../sysdeps/unix/sysv/linux/pselect.c:48
48      ../sysdeps/unix/sysv/linux/pselect.c: No such file or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not
from terminal]
DISPLAY = :0
TERM = xterm
Breakpoint 1 at 0x55e20e9cddbd: file emacs.c, line 379.
Breakpoint 2 at 0x55e20e97f6f6: file xterm.c, line 10145.
#0  0x00007f696c484246 in __pselect (nfds=9, readfds=0x7ffdf9111050,
writefds=0x7ffdf91110d0, exceptfds=0x0, timeout=<optimized out>,
sigmask=<optimized out>) at ../sysdeps/unix/sysv/linux/pselect.c:48
#1  0x000055e20ec8afbe in really_call_select (arg=0x7ffdf9110f40) at
thread.c:586
#2  0x000055e20eaf10ff in flush_stack_call_func (func=0x55e20ec8aef3
<really_call_select>, arg=0x7ffdf9110f40) at alloc.c:4951
#3  0x000055e20ec8b0ba in thread_select (func=0x7f696c484180
<__pselect>, max_fds=9, rfds=0x7ffdf9111050, wfds=0x7ffdf91110d0,
efds=0x0, timeout=0x7ffdf9111680, sigmask=0x0) at thread.c:616
#4  0x000055e20ecf3770 in xg_select (fds_lim=9, rfds=0x7ffdf91116f0,
wfds=0x7ffdf9111770, efds=0x0, timeout=0x7ffdf9111680, sigmask=0x0) at
xgselect.c:117
#5  0x000055e20ebfcc7c 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:5572
#6  0x000055e20e7bd946 in sit_for (timeout=make_fixnum(30),
reading=true, display_option=1) at dispnew.c:6064
#7  0x000055e20e9e098f in read_char (commandflag=1,
map=XIL(0x55e210f25583), prev_event=XIL(0),
used_mouse_menu=0x7ffdf9111d05, end_time=0x0) at keyboard.c:2738
#8  0x000055e20e9f373b in read_key_sequence (keybuf=0x7ffdf9111ef0,
prompt=XIL(0), dont_downcase_last=false, can_return_switch_frame=true,
fix_current_buffer=true, prevent_redisplay=false) at keyboard.c:9554
#9  0x000055e20e9dbf70 in command_loop_1 () at keyboard.c:1350
#10 0x000055e20eb53339 in internal_condition_case (bfun=0x55e20e9dbad2
<command_loop_1>, handlers=XIL(0x90), hfun=0x55e20e9db082 <cmd_error>)
at eval.c:1356
#11 0x000055e20e9db693 in command_loop_2 (ignore=XIL(0)) at keyboard.c:1091
#12 0x000055e20eb5271c in internal_catch (tag=XIL(0x5520),
func=0x55e20e9db662 <command_loop_2>, arg=XIL(0)) at eval.c:1117
#13 0x000055e20e9db5bd in command_loop () at keyboard.c:1062
#14 0x000055e20e9dab49 in recursive_edit_1 () at keyboard.c:714
#15 0x000055e20ea65f65 in read_minibuf (map=XIL(0x55e210f26463),
initial=XIL(0x55e210b75c74), prompt=XIL(0x7f69691842ac),
expflag=false, histvar=XIL(0x5c10), histpos=make_fixnum(0),
defalt=XIL(0x55e210afa4c4), allow_props=false,
inherit_input_method=false) at minibuf.c:664
#16 0x000055e20ea66bed in Fread_from_minibuffer
(prompt=XIL(0x7f69691842ac), initial_contents=XIL(0x55e210b75c74),
keymap=XIL(0x55e210f26463), read=XIL(0), hist=XIL(0x5c10),
default_value=XIL(0x55e210afa4c4), inherit_input_method=XIL(0)) at
minibuf.c:943
#17 0x000055e20eb57f53 in funcall_subr (subr=0x55e20f3745c0
<Sread_from_minibuffer>, numargs=7, args=0x7ffdf91124a0) at
eval.c:2888
#18 0x000055e20eb57840 in Ffuncall (nargs=8, args=0x7ffdf9112498) at eval.c:2795
#19 0x000055e20ebe2a43 in exec_byte_code (bytestr=XIL(0x7f696918da7c),
vector=XIL(0x7f6969189d15), maxdepth=make_fixnum(18),
args_template=make_fixnum(2050), nargs=8, args=0x7ffdf91129f8) at
bytecode.c:633
#20 0x000055e20eb58581 in funcall_lambda (fun=XIL(0x7f6969189ce5),
nargs=8, arg_vector=0x7ffdf91129b8) at eval.c:2990
#21 0x000055e20eb57884 in Ffuncall (nargs=9, args=0x7ffdf91129b0) at eval.c:2797
#22 0x000055e20ea68b4c in Fcompleting_read
(prompt=XIL(0x7f69691842ac), collection=XIL(0x298759c9ff28),
predicate=XIL(0x5a60), require_match=XIL(0x298759c85468),
initial_input=XIL(0x55e210b75c74), hist=XIL(0x5c10),
def=XIL(0x55e210afa4c4), inherit_input_method=XIL(0)) at
minibuf.c:1658
#23 0x000055e20eb57fba in funcall_subr (subr=0x55e20f3747c0
<Scompleting_read>, numargs=7, args=0x7ffdf9112bb0) at eval.c:2893
#24 0x000055e20eb57840 in Ffuncall (nargs=8, args=0x7ffdf9112ba8) at eval.c:2795
#25 0x000055e20ebe2a43 in exec_byte_code (bytestr=XIL(0x7f69692fbfac),
vector=XIL(0x7f69690924ad), maxdepth=make_fixnum(22),
args_template=make_fixnum(1537), nargs=6, args=0x7ffdf9113260) at
bytecode.c:633
#26 0x000055e20eb58581 in funcall_lambda (fun=XIL(0x7f696909247d),
nargs=6, arg_vector=0x7ffdf9113230) at eval.c:2990
#27 0x000055e20eb57884 in Ffuncall (nargs=7, args=0x7ffdf9113228) at eval.c:2797
#28 0x000055e20ebe2a43 in exec_byte_code (bytestr=XIL(0x7f69692fc05c),
vector=XIL(0x7f6969092435), maxdepth=make_fixnum(13),
args_template=make_fixnum(1537), nargs=4, args=0x7ffdf9113700) at
bytecode.c:633
#29 0x000055e20eb58581 in funcall_lambda (fun=XIL(0x7f6969092405),
nargs=4, arg_vector=0x7ffdf91136e0) at eval.c:2990
#30 0x000055e20eb57884 in Ffuncall (nargs=5, args=0x7ffdf91136d8) at eval.c:2797
#31 0x000055e20ebe2a43 in exec_byte_code (bytestr=XIL(0x7f69691872ec),
vector=XIL(0x7f69691872c5), maxdepth=make_fixnum(7),
args_template=make_fixnum(514), nargs=2, args=0x7ffdf9113b80) at
bytecode.c:633
#32 0x000055e20eb58581 in funcall_lambda (fun=XIL(0x7f6969187295),
nargs=2, arg_vector=0x7ffdf9113b70) at eval.c:2990
#33 0x000055e20eb57884 in Ffuncall (nargs=3, args=0x7ffdf9113b68) at eval.c:2797
#34 0x000055e20ebe2a43 in exec_byte_code (bytestr=XIL(0x7f696918734c),
vector=XIL(0x7f696921c03d), maxdepth=make_fixnum(3),
args_template=XIL(0), nargs=0, args=0x0) at bytecode.c:633
#35 0x000055e20ebe1a3a in Fbyte_code (bytestr=XIL(0x7f696918734c),
vector=XIL(0x7f696921c03d), maxdepth=make_fixnum(3)) at bytecode.c:322
#36 0x000055e20eb55e6c in eval_sub (form=XIL(0x7f696921c00b)) at eval.c:2280
#37 0x000055e20eb55266 in Feval (form=XIL(0x7f696921c00b),
lexical=XIL(0)) at eval.c:2103
#38 0x000055e20eb4584f in Fcall_interactively
(function=XIL(0x298759e29538), record_flag=XIL(0),
keys=XIL(0x55e210ff6da5)) at callint.c:323
#39 0x000055e20eb57e25 in funcall_subr (subr=0x55e20f379900
<Scall_interactively>, numargs=3, args=0x7ffdf9114390) at eval.c:2873
#40 0x000055e20eb57840 in Ffuncall (nargs=4, args=0x7ffdf9114388) at eval.c:2795
#41 0x000055e20ebe2a43 in exec_byte_code (bytestr=XIL(0x7f6969228984),
vector=XIL(0x7f69692286dd), maxdepth=make_fixnum(13),
args_template=make_fixnum(1025), nargs=1, args=0x7ffdf91148c0) at
bytecode.c:633
#42 0x000055e20eb58581 in funcall_lambda (fun=XIL(0x7f69692286ad),
nargs=1, arg_vector=0x7ffdf91148b8) at eval.c:2990
#43 0x000055e20eb57884 in Ffuncall (nargs=2, args=0x7ffdf91148b0) at eval.c:2797
#44 0x000055e20eb5703f in call1 (fn=XIL(0x3d50),
arg1=XIL(0x298759e29538)) at eval.c:2655
#45 0x000055e20e9dc38d in command_loop_1 () at keyboard.c:1463
#46 0x000055e20eb53339 in internal_condition_case (bfun=0x55e20e9dbad2
<command_loop_1>, handlers=XIL(0x90), hfun=0x55e20e9db082 <cmd_error>)
at eval.c:1356
#47 0x000055e20e9db693 in command_loop_2 (ignore=XIL(0)) at keyboard.c:1091
#48 0x000055e20eb5271c in internal_catch (tag=XIL(0xcc60),
func=0x55e20e9db662 <command_loop_2>, arg=XIL(0)) at eval.c:1117
#49 0x000055e20e9db62d in command_loop () at keyboard.c:1070
#50 0x000055e20e9dab49 in recursive_edit_1 () at keyboard.c:714
#51 0x000055e20e9dad49 in Frecursive_edit () at keyboard.c:786
#52 0x000055e20e9d075d in main (argc=2, argv=0x7ffdf9114da8) at emacs.c:2067

Lisp Backtrace:
"read-from-minibuffer" (0xf91124a0)
"completing-read-default" (0xf91129b8)
"completing-read" (0xf9112bb0)
"read-file-name-default" (0xf9113230)
"read-file-name" (0xf91136e0)
"find-file-read-args" (0xf9113b70)
"byte-code" (0xf9113fa0)
"call-interactively" (0xf9114390)
"command-execute" (0xf91148b8)
"read-from-minibuffer" (0xf91124a0)
"completing-read-default" (0xf91129b8)
"completing-read" (0xf9112bb0)
"read-file-name-default" (0xf9113230)
"read-file-name" (0xf91136e0)
"find-file-read-args" (0xf9113b70)
"byte-code" (0xf9113fa0)
"call-interactively" (0xf9114390)
"command-execute" (0xf91148b8)
[Inferior 1 (process 1409856) detached]

I thought Emacs might be asking some question, but if so:
1. Either the question comes from C code or there's something unusual
about the context of the question that causes no Lisp backtrace to
show up.
2. A prompt is inconsistent with my reading of the code of
highlight-changes-mode, whereas an error is consistent.

Obviously it would be easier to fix #47439 first. I consider that one
more important. I originally encountered this bug when I logged in,
which runs an Emacs daemon and restores my session. Having one
buffer's modes not properly restored because highlight-changes-mode
errored out would be a very minor problem. Having the session only
partly restored because desktop-read errored out, but having a
backtrace including highlight-changes-mode and desktop-read, would
have made the problem easy to diagnose. Just having an Emacs process
that wasn't responding was painful.

-- Gilles

On Sun, 28 Mar 2021 at 08:36, Eli Zaretskii <[email-masked]> wrote:
>
> > From: Gilles <[email-masked]>
> > Date: Sun, 28 Mar 2021 03:06:25 +0200
> > Cc: [email-masked]
> >
> > It appears that Emacs is waiting for input from an event object. I
> > have no idea what that event object is about, or why the daemon would
> > be waiting for input before starting the server.
>
> I'm guessing that Emacs asked a question and is waiting for the user
> to answer it.  But since you don't show the Lisp backtrace, it's hard
> to know for sure.  If you type "xbacktrace", does GDB show the Lisp
> backtrace?
>
> > Turning on highlight-changes-mode should not depend on the
> > capabilities of the current terminal or display, since this can change
> > as new frames are attached.
>
> We don't yet know if this is the problem, and thus hypothesis is
> inconsistent with the fact that Emacs is waiting for the user to
> answer some question.
>
> Thanks.