Subject: Re: bug#45277: D-Bus crashes and DND errors

From: Michael Albinus <[email-masked]>
Date: Mon, 28 Dec 2020 18:52:33 +0100

Juri Linkov <[email-masked]> writes:

Hi Juri,

> But when such error is signaled:
>
>   Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p "Click to close tab")
>     dbus-handle-event((dbus-event :help "Click to close tab"))
>     funcall-interactively(dbus-handle-event (dbus-event :help "Click to close tab"))
>     call-interactively(dbus-handle-event nil [(dbus-event :help "Click to close tab")])
>     command-execute(dbus-handle-event nil [(dbus-event :help "Click to close tab")] t)
>
> there were no DBUS_DEBUG messages before this error comes.
> So the erroneous events are not added by dbusbind.c.

Good.

> Here's is a brief sequence of events:
>
> 1. In web browser copied a URL to the clipboard;
> 2. In Emacs this immediately causes a DBUS_EVENT event added to kbd_buffer:
>
> Thread 1 "emacs" hit Breakpoint 5, make_lispy_event (event=0x555555cb93c8 <kbd_buffer+100520>) at keyboard.c:6015
> 6015		return Fcons (Qdbus_event, event->arg);
>
> (gdb) bt
> #0  make_lispy_event (event=0x555555cb93c8 <kbd_buffer+100520>) at keyboard.c:6015
> #1  0x00005555557131b9 in kbd_buffer_get_event (kbp=0x7fffffffc668, used_mouse_menu=0x7fffffffdcb9, end_time=0x0) at keyboard.c:3978
> #2  0x000055555570ed06 in read_event_from_main_queue (end_time=0x0, local_getcjmp=0x7fffffffcab0, used_mouse_menu=0x7fffffffdcb9) at keyboard.c:2159
> #3  0x000055555570f023 in read_decoded_event_from_main_queue (end_time=0x0, local_getcjmp=0x7fffffffcab0, prev_event=XIL(0), used_mouse_menu=0x7fffffffdcb9) at keyboard.c:2223
> #4  0x0000555555710857 in read_char (commandflag=1, map=XIL(0x55555a5c9943), prev_event=XIL(0), used_mouse_menu=0x7fffffffdcb9, end_time=0x0) at keyboard.c:2833
> #5  0x000055555571fab7 in read_key_sequence (keybuf=0x7fffffffdee0, prompt=XIL(0), dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false) at keyboard.c:9498
> #6  0x000055555570c918 in command_loop_1 () at keyboard.c:1353
> #7  0x00005555557caed4 in internal_condition_case (bfun=0x55555570c4b0 <command_loop_1>, handlers=XIL(0x90), hfun=0x55555570bbed <cmd_error>) at eval.c:1415
> #8  0x000055555570c154 in command_loop_2 (ignore=XIL(0)) at keyboard.c:1094
> #9  0x00005555557ca6d7 in internal_catch (tag=XIL(0xd800), func=0x55555570c123 <command_loop_2>, arg=XIL(0)) at eval.c:1176
> #10 0x000055555570c0ef in command_loop () at keyboard.c:1073
> #11 0x000055555570b79e in recursive_edit_1 () at keyboard.c:720
> #12 0x000055555570b929 in Frecursive_edit () at keyboard.c:789
> #13 0x00005555557080a0 in main (argc=1, argv=0x7fffffffe368) at emacs.c:2054
>
> (gdb) fr 1
> #1  0x00005555557131b9 in kbd_buffer_get_event (kbp=0x7fffffffc668, used_mouse_menu=0x7fffffffdcb9, end_time=0x0) at keyboard.c:3978
> 3978	          obj = make_lispy_event (&event->ie);
>
> (gdb) p event->kind
> $1 = DBUS_EVENT
>
> (gdb) p (int)event->kind
> $2 = 27
>
> (gdb) p event->ie
> $3 = {
>   kind = DBUS_EVENT,
>   part = scroll_bar_nowhere,
>   code = 0,
>   modifiers = 0,
>   x = XIL(0),
>   y = XIL(0),
>   timestamp = 0,
>   frame_or_window = XIL(0),
>   arg = XIL(0x555557db7e23)
> }
>
> (gdb) p event->ie->arg
> $4 = XIL(0x555557db7e23)
>
> (gdb) pr
> (:help "Click to close tab")
>
> (gdb) p event->sie
> $5 = {
>   kind = DBUS_EVENT,
>   dpyinfo = 0x0,
>   requestor = 0,
>   selection = 0,
>   target = 0,
>   property = 0,
>   time = 0
> }
>
> (gdb) c
> Continuing.
>
> Thread 1 "emacs" hit Breakpoint 5, make_lispy_event (event=0x555555cbd0d0 <kbd_buffer+116144>) at keyboard.c:6015
> 6015		return Fcons (Qdbus_event, event->arg);
>
> (gdb) fr 1
> #1  0x00005555557131b9 in kbd_buffer_get_event (kbp=0x7fffffffc668, used_mouse_menu=0x7fffffffdcb9, end_time=0x0) at keyboard.c:3978
> 3978	          obj = make_lispy_event (&event->ie);
>
> (gdb) p event->kind
> $6 = DBUS_EVENT
>
> (gdb) p event->ie
> $7 = {
>   kind = DBUS_EVENT,
>   part = scroll_bar_nowhere,
>   code = 0,
>   modifiers = 0,
>   x = XIL(0),
>   y = XIL(0),
>   timestamp = 0,
>   frame_or_window = XIL(0),
>   arg = XIL(0x555560a70f43)
> }
>
> (gdb) p event->ie->arg
> $8 = XIL(0x555560a70f43)
>
> (gdb) pr
> #<INVALID_LISP_OBJECT 0x555560a70f43>
>
> (gdb) c
> Continuing.
>
> Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
> string_intervals (s=XIL(0x6c613a5b5e5b285c)) at lisp.h:3404
> 3404	  return XSTRING (s)->u.s.intervals;
>
> Maybe making bootstrap after every pull from master will solve these problems?

That would be too drastic. I have the impression, that the enum
event_kind (termhooks.h) is not in sync with its usage here and
there. When this file is changed, all *.c files (or at least all *.c
files using this) shall be recompiled.

In your local git checkout, what are the timestamps of termhooks.h,
dbusbind.c and dbusbind.o?

Best regards, Michael.