Subject: bug#79367: 31.0.50; magit-commit sometimes doesn't work if diff-hl-update-async is t

From: Zhengyi Fu <[email-masked]>
Date: Sat, 06 Sep 2025 13:35:49 +0800

Eli Zaretskii <[email-masked]> writes:

>> From: Zhengyi Fu <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Fri, 05 Sep 2025 21:36:16 +0800
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> > Thanks, then please show the value of the offending descriptor which
>> > causes the assertion violation.  For that, please run Emacs udner GDB,
>> > perform the recipe that reproduces the problem, and then type these
>> > GDB commands:
>> >
>> >  (gdb) frame 1
>> >  (gdb) print p->infd
>> >
>> > and tell what that produces.
>> 
>> The p->infd value is 8.
>
> OK, please repeat this several times to make sure it's always 8.
>
> If it is, then let's try to see which code leaves the .thread field
> uncleared.  Like this (please run from the src directory where you
> have the 'emacs' executable you have built):
>
>   $ gdb ./emacs
>   ...
>   (gdb) break process.c:8731
>   (gdb) run
>
> Emacs will start and stop in init_process_emacs, on line 8731 of
> process.c.  Then:
>
>   (gdb) watch fd_callback_info[8].thread
>   (gdb) commands
>    > bt 5
>    > continue
>    > end
>   (gdb) continue
>
> The above sets a watchpoint which will stop Emacs each time we assign
> some value to fd_callback_info[8].thread, and GDB will then show the
> first 5 frames of the call-stack, then continue.  Now run your recipe,
> until it gets SIGABRT, and post everything GDB produced until that
> point.  I hope that will tell us which code fails to clear the .thread
> member.
>
> Thanks.

The fd is 8 when running Emacs in terminal.
The fd is always 16 when running Emacs in X11.

GNU gdb (Fedora Linux) 16.3-1.fc42
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./emacs...
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.0
TERM = foot
Breakpoint 1 at 0x556a1d: file emacs.c, line 442.
Breakpoint 2 at 0x5211c6: file xterm.c, line 27074.
Breakpoint 3 at 0x600880: file eval.c, line 3108.
(gdb) break process.c:8731
Breakpoint 4 at 0x6610d8: file process.c, line 8732.
(gdb) run
Starting program: /home/zhengyi/src/emacs_master/src/emacs -Q -l /home/zhengyi/.config/emacs/straight/repos/straight.el/bootstrap.el --eval '
'\(progn\ '
'\(straight-use-package\ \'diff-hl\)'
'\(straight-use-package\ \'magit\)'
'\(setq\ diff-hl-update-async\ t\)'
'\(global-diff-hl-mode\)'
'\)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 4, init_process_emacs (sockfd=sockfd@entry=-1) at process.c:8732
8732	 num_pending_connects = 0;
Missing rpms, try: dnf --enablerepo='*debug*' install gtk3-debuginfo-3.24.49-2.fc42.x86_64 zlib-ng-compat-debuginfo-2.2.5-2.fc42.x86_64 pango-debuginfo-1.56.4-1.fc42.x86_64 harfbuzz-debuginfo-10.4.0-1.fc42.x86_64 atk-debuginfo-2.56.3-1.fc42.x86_64 cairo-gobject-debuginfo-1.18.2-3.fc42.x86_64 cairo-debuginfo-1.18.2-3.fc42.x86_64 gdk-pixbuf2-debuginfo-2.42.12-12.fc42.x86_64 glib2-debuginfo-2.84.4-1.fc42.x86_64 libX11-debuginfo-1.8.12-1.fc42.x86_64 libX11-xcb-debuginfo-1.8.12-1.fc42.x86_64 libxcb-debuginfo-1.17.0-5.fc42.x86_64 libXrandr-debuginfo-1.5.4-5.fc42.x86_64 libXinerama-debuginfo-1.1.5-8.fc42.x86_64 libXfixes-debuginfo-6.0.1-5.fc42.x86_64 libXext-debuginfo-1.3.6-3.fc42.x86_64 ncurses-libs-debuginfo-6.5-5.20250125.fc42.x86_64 glibc-debuginfo-2.41-11.fc42.x86_64 gmp-debuginfo-6.3.0-4.fc42.x86_64 libXcomposite-debuginfo-0.4.6-5.fc42.x86_64 fontconfig-debuginfo-2.16.0-2.fc42.x86_64 fribidi-debuginfo-1.0.16-2.fc42.x86_64 libepoxy-debuginfo-1.5.10-9.fc42.x86_64 libXi-debuginfo-1.8.2-2.fc42.x86_64 at-spi2-atk-debuginfo-2.56.3-1.fc42.x86_64 libcloudproviders-debuginfo-0.3.6-1.fc42.x86_64 libtinysparql-debuginfo-3.9.2-1.fc42.x86_64 libwayland-client-debuginfo-1.24.0-1.fc42.x86_64 libxkbcommon-debuginfo-1.8.1-1.fc42.x86_64 libwayland-cursor-debuginfo-1.24.0-1.fc42.x86_64 libwayland-egl-debuginfo-1.24.0-1.fc42.x86_64 libXcursor-debuginfo-1.2.3-2.fc42.x86_64 libXdamage-debuginfo-1.1.6-5.fc42.x86_64 libthai-debuginfo-0.1.29-10.fc42.x86_64 freetype-debuginfo-2.13.3-2.fc42.x86_64 graphite2-debuginfo-1.3.14-18.fc42.x86_64 libpng-debuginfo-1.6.44-2.fc42.x86_64 libXrender-debuginfo-0.9.12-2.fc42.x86_64 pixman-debuginfo-0.46.2-1.fc42.x86_64 libjpeg-turbo-debuginfo-3.1.0-2.fc42.x86_64 libmount-debuginfo-2.40.4-7.fc42.x86_64 libselinux-debuginfo-3.8-2.fc42.x86_64 libffi-debuginfo-3.4.6-5.fc42.x86_64 pcre2-debuginfo-10.45-1.fc42.x86_64 libXau-debuginfo-1.0.12-2.fc42.x86_64 libxml2-debuginfo-2.12.10-1.fc42.x86_64 at-spi2-core-debuginfo-2.56.3-1.fc42.x86_64 dbus-libs-debuginfo-1.16.0-3.fc42.x86_64 libgcc-debuginfo-15.2.1-1.fc42.x86_64 json-glib-debuginfo-1.10.6-2.fc42.x86_64 sqlite-libs-debuginfo-3.47.2-2.fc42.x86_64 libdatrie-debuginfo-0.2.13-11.fc42.x86_64 bzip2-libs-debuginfo-1.0.8-20.fc42.x86_64 libbrotli-debuginfo-1.1.0-6.fc42.x86_64 libblkid-debuginfo-2.40.4-7.fc42.x86_64 xz-libs-debuginfo-5.8.1-2.fc42.x86_64 systemd-libs-debuginfo-257.7-1.fc42.x86_64 libcap-debuginfo-2.73-2.fc42.x86_64
(gdb) watch fd_callback_info[16].thread
Hardware watchpoint 5: fd_callback_info[16].thread
(gdb) commands
Type commands for breakpoint(s) 5, one per line.
End with a line saying just "end".
>bt 5
>continue
>end
(gdb) continue
Continuing.
[New Thread 0x7fffe6bfe6c0 (LWP 741835)]
[New Thread 0x7fffe63fd6c0 (LWP 741836)]
[New Thread 0x7fffe5bfc6c0 (LWP 741837)]
[New Thread 0x7fffe4fff6c0 (LWP 741838)]
[New Thread 0x7fffd7fff6c0 (LWP 741839)]
[New Thread 0x7fffd77fe6c0 (LWP 741840)]
[Detaching after vfork from child process 741841]
[Detaching after vfork from child process 741842]
[Detaching after vfork from child process 741843]
[Detaching after vfork from child process 741845]
[Detaching after vfork from child process 741846]
[Detaching after vfork from child process 741847]
[Detaching after vfork from child process 741848]
[Detaching after vfork from child process 741849]
[Detaching after vfork from child process 741850]
[Detaching after vfork from child process 741851]
[Detaching after vfork from child process 741852]
[Detaching after vfork from child process 741853]
[Detaching after vfork from child process 741854]
[Detaching after vfork from child process 741865]
[Detaching after vfork from child process 741866]
[Detaching after vfork from child process 741867]
[Detaching after vfork from child process 741868]
[Detaching after vfork from child process 741869]
[Detaching after vfork from child process 741870]
[Detaching after vfork from child process 741871]
[Detaching after vfork from child process 741872]
[Detaching after vfork from child process 741873]
[Detaching after vfork from child process 741874]
[Detaching after vfork from child process 741885]
[Detaching after vfork from child process 741896]
[Detaching after vfork from child process 741897]
[Detaching after vfork from child process 741898]
[Detaching after vfork from child process 741899]
[Detaching after vfork from child process 741900]
[Detaching after vfork from child process 741901]
[Detaching after vfork from child process 741902]
[Detaching after vfork from child process 741903]
[Detaching after vfork from child process 741904]
[Detaching after vfork from child process 741905]
[Detaching after vfork from child process 741906]
[Detaching after vfork from child process 741907]
[Detaching after vfork from child process 741908]
[Detaching after vfork from child process 741909]
[Detaching after vfork from child process 741910]
[Detaching after vfork from child process 741911]
[Detaching after vfork from child process 741912]
[Detaching after vfork from child process 741913]
[Detaching after vfork from child process 741914]
[Detaching after vfork from child process 741915]
[Detaching after vfork from child process 741916]
[Detaching after vfork from child process 741917]
[Detaching after vfork from child process 741918]
[Detaching after vfork from child process 741919]
[Detaching after vfork from child process 741920]
[Detaching after vfork from child process 741921]
[Detaching after vfork from child process 741922]
[Detaching after vfork from child process 741923]
[Detaching after vfork from child process 741924]
[Detaching after vfork from child process 741925]
[Detaching after vfork from child process 741926]
[Detaching after vfork from child process 741927]
[Detaching after vfork from child process 741928]
[Detaching after vfork from child process 741929]
[Detaching after vfork from child process 741930]

Thread 1 "emacs" hit Hardware watchpoint 5: fd_callback_info[16].thread

Old value = (struct thread_state *) 0x0
New value = (struct thread_state *) 0x74dba0 <main_thread>
set_proc_thread (proc=proc@entry=0x1eef868, thrd=0x74dba0 <main_thread>) at process.c:1457
1457	 eassert (proc->outfd < FD_SETSIZE);
#0  set_proc_thread (proc=proc@entry=0x1eef868, thrd=0x74dba0 <main_thread>) at process.c:1457
#1  0x000000000065e232 in server_accept_connection
    (server=<optimized out>, channel=<optimized out>) at process.c:5134
#2  wait_reading_process_output
    (time_limit=time_limit@entry=30, nsecs=nsecs@entry=0, read_kbd=read_kbd@entry=-1, do_display=do_display@entry=true, wait_for_cell=wait_for_cell@entry=0x0, wait_proc=wait_proc@entry=0x0, just_wait_proc=0) at process.c:5990
#3  0x000000000041217a in sit_for
    (timeout=<optimized out>, reading=reading@entry=true, display_option=display_option@entry=1)
    at dispnew.c:6978
#4  0x000000000056b4cb in read_char
    (commandflag=1, map=map@entry=0x1ed2c83, prev_event=0x0, used_mouse_menu=used_mouse_menu@entry=0x7fffffffd62b, end_time=end_time@entry=0x0) at keyboard.c:2925
[Detaching after vfork from child process 741972]
[Detaching after vfork from child process 741973]
[Detaching after vfork from child process 741974]
[Detaching after vfork from child process 741975]
[Detaching after vfork from child process 741976]
[Detaching after vfork from child process 741977]
[Detaching after vfork from child process 741978]
[Detaching after vfork from child process 741979]
[Detaching after vfork from child process 741980]
[Detaching after vfork from child process 741981]
[Detaching after vfork from child process 741982]
[Detaching after vfork from child process 741983]
[Detaching after vfork from child process 741984]
[Detaching after vfork from child process 741985]
[Detaching after vfork from child process 741986]
[Detaching after vfork from child process 741987]
[Detaching after vfork from child process 741988]
[Detaching after vfork from child process 741989]
[Detaching after vfork from child process 741990]
[Detaching after vfork from child process 741991]
[Detaching after vfork from child process 741992]
[Detaching after vfork from child process 741993]
[Detaching after vfork from child process 741994]
[Detaching after vfork from child process 741995]
[Detaching after vfork from child process 741996]
[Detaching after vfork from child process 741997]
[Detaching after vfork from child process 741998]
[Detaching after vfork from child process 741999]
[Detaching after vfork from child process 742000]
[Detaching after vfork from child process 742001]
[Detaching after vfork from child process 742002]
[Detaching after vfork from child process 742003]
[Detaching after vfork from child process 742004]
[Detaching after vfork from child process 742005]
[Detaching after vfork from child process 742006]
[Detaching after vfork from child process 742007]
[Detaching after vfork from child process 742008]
[Detaching after vfork from child process 742009]
[Detaching after vfork from child process 742020]
[Detaching after vfork from child process 742021]
[Detaching after vfork from child process 742022]
[Detaching after vfork from child process 742023]
[Detaching after vfork from child process 742024]
[Detaching after vfork from child process 742025]
[Detaching after vfork from child process 742026]
[Detaching after vfork from child process 742027]
[Detaching after vfork from child process 742028]
[Detaching after vfork from child process 742029]
[Detaching after vfork from child process 742030]
[Detaching after vfork from child process 742031]
[Detaching after vfork from child process 742032]
[New Thread 0x7fffc9fff6c0 (LWP 742033)]
[Thread 0x7fffc9fff6c0 (LWP 742033) exited]

Thread 1 "emacs" hit Hardware watchpoint 5: fd_callback_info[16].thread

Old value = (struct thread_state *) 0x74dba0 <main_thread>
New value = (struct thread_state *) 0x0
clear_fd_callback_data (elem=0x7ec320 <fd_callback_info+640>) at process.c:476
476	 elem->waiting_thread = NULL;
#0  clear_fd_callback_data (elem=0x7ec320 <fd_callback_info+640>) at process.c:476
#1  delete_keyboard_wait_descriptor (desc=desc@entry=16) at process.c:8341
#2  0x0000000000657ad1 in delete_read_fd (fd=16) at process.c:519
#3  deactivate_process (proc=proc@entry=0x1eef86d) at process.c:4852
#4  0x0000000000657b4a in remove_process (proc=proc@entry=0x1eef86d) at process.c:965

Lisp Backtrace:
"delete-process" (0xe6bff1a0)
"with-editor-return" (0xe6bff120)
"with-editor-cancel" (0xffffd320)
"funcall-interactively" (0xffffd318)
"call-interactively" (0xe6bff070)
"command-execute" (0xffffd838)
[Detaching after vfork from child process 742034]
[Detaching after vfork from child process 742035]
[Detaching after vfork from child process 742036]
[Detaching after vfork from child process 742037]
[Detaching after vfork from child process 742038]
[Detaching after vfork from child process 742039]
[Detaching after vfork from child process 742040]
[Detaching after vfork from child process 742041]
[Detaching after vfork from child process 742042]
[Detaching after vfork from child process 742043]
[Detaching after vfork from child process 742054]
[Detaching after vfork from child process 742055]
[Detaching after vfork from child process 742056]
[Detaching after vfork from child process 742057]
[Detaching after vfork from child process 742058]
[Detaching after vfork from child process 742059]
[Detaching after vfork from child process 742060]
[Detaching after vfork from child process 742061]
[Detaching after vfork from child process 742062]
[Detaching after vfork from child process 742063]
[Detaching after vfork from child process 742064]
[Detaching after vfork from child process 742065]
[Detaching after vfork from child process 742076]
[Detaching after vfork from child process 742087]
[Detaching after vfork from child process 742088]
[Detaching after vfork from child process 742089]
[Detaching after vfork from child process 742090]
[Detaching after vfork from child process 742091]
[Detaching after vfork from child process 742092]
[Detaching after vfork from child process 742093]
[Detaching after vfork from child process 742094]
[Detaching after vfork from child process 742095]
[Detaching after vfork from child process 742096]
[Detaching after vfork from child process 742097]
[Detaching after vfork from child process 742098]
[Detaching after vfork from child process 742099]
[Detaching after vfork from child process 742100]
[Detaching after vfork from child process 742101]
[Detaching after vfork from child process 742102]
[Thread 0x7fffd7fff6c0 (LWP 741839) exited]
[Thread 0x7fffe4fff6c0 (LWP 741838) exited]
[Detaching after vfork from child process 742103]
[Detaching after vfork from child process 742104]
[Detaching after vfork from child process 742105]
[Detaching after vfork from child process 742106]
[Detaching after vfork from child process 742107]
[Detaching after vfork from child process 742108]
[Detaching after vfork from child process 742109]
[Detaching after vfork from child process 742110]
[Detaching after vfork from child process 742111]
[Detaching after vfork from child process 742112]
[Detaching after vfork from child process 742113]
[Detaching after vfork from child process 742114]
[Detaching after vfork from child process 742115]
[Detaching after vfork from child process 742126]
[Detaching after vfork from child process 742127]
[New Thread 0x7fffd7fff6c0 (LWP 742128)]
[Detaching after vfork from child process 742129]
[Switching to Thread 0x7fffd7fff6c0 (LWP 742128)]

Thread 9 "diff-hl--update" hit Hardware watchpoint 5: fd_callback_info[16].thread

Old value = (struct thread_state *) 0x0
New value = (struct thread_state *) 0x1321ae0
0x0000000000651f83 in set_proc_thread (proc=proc@entry=0x1b83050, thrd=0x1321ae0)
    at process.c:1460
1460	}
#0  0x0000000000651f83 in set_proc_thread (proc=proc@entry=0x1b83050, thrd=0x1321ae0)
    at process.c:1460
#1  0x0000000000659a8e in create_process
    (process=0x1b83055, new_argv=0x7fffd7ffcdd0, current_dir=0x1f29a94) at process.c:2272
#2  Fmake_process (nargs=<optimized out>, args=<optimized out>) at process.c:2090
#3  0x0000000000606144 in funcall_subr
    (subr=<optimized out>, numargs=numargs@entry=6, args=args@entry=0x7fffd7ffd088) at eval.c:3265
#4  0x0000000000608801 in funcall_general
    (fun=<optimized out>, numargs=numargs@entry=6, args=args@entry=0x7fffd7ffd088) at eval.c:3121

Lisp Backtrace:
0x761740 PVEC_SUBR
"apply" (0x1faad78)
"make-process@with-editor-process-filter" (0xd7ffd308)
"apply" (0x1faacd0)
"make-process" (0xd7ffd598)
"apply" (0x1faac70)
"start-process" (0xd7ffd818)
"apply" (0x1faabf8)
0xf525cd80 PVEC_CLOSURE
"apply" (0x1faab80)
"start-file-process@with-editor-process-filter" (0xd7ffdd78)
"apply" (0x1faab18)
"start-file-process" (0xd7ffe028)
"apply" (0x1faaab8)
"vc-do-command" (0xd7ffe2d8)
"apply" (0x1faa9e0)
"vc-git-command" (0xd7ffe588)
"apply" (0x1faa930)
"vc-git-diff" (0xd7ffe828)
"apply" (0x1faa8a0)
"vc-call-backend" (0x1faa810)
"diff-hl-diff-against-reference" (0x1faa7a8)
"diff-hl-changes-buffer" (0x1faa760)
"diff-hl-changes" (0x1faa6b0)
"diff-hl--update" (0x1faa668)
"diff-hl--update-safe" (0x1faa638)
0x1f51d38 PVEC_CLOSURE
[Detaching after vfork from child process 742130]
[Thread 0x7fffd7fff6c0 (LWP 742128) exited]
[Detaching after vfork from child process 742141]
[Detaching after vfork from child process 742142]
[Detaching after vfork from child process 742143]
[Detaching after vfork from child process 742144]
[Detaching after vfork from child process 742145]
[Detaching after vfork from child process 742146]
[Detaching after vfork from child process 742147]
[Detaching after vfork from child process 742148]
[Detaching after vfork from child process 742149]
[Detaching after vfork from child process 742150]
[Detaching after vfork from child process 742151]
[Detaching after vfork from child process 742152]
[Detaching after vfork from child process 742153]
[Detaching after vfork from child process 742154]
[Detaching after vfork from child process 742155]
[Detaching after vfork from child process 742156]
[Detaching after vfork from child process 742157]
[Detaching after vfork from child process 742158]
[Detaching after vfork from child process 742159]
[Detaching after vfork from child process 742160]
[Detaching after vfork from child process 742161]

process.c:5128: Emacs fatal error: assertion failed: !fd_callback_info[p->infd].thread
[Switching to Thread 0x7ffff5d91ac0 (LWP 741828)]

Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=sig@entry=6, 
    backtrace_limit=backtrace_limit@entry=2147483647) at emacs.c:442
442	{
Missing rpms, try: dnf --enablerepo='*debug*' install gvfs-client-debuginfo-1.57.2-1.fc42.x86_64 fcitx5-gtk3-debuginfo-5.1.4-1.fc42.x86_64 fcitx5-gtk-debuginfo-5.1.4-1.fc42.x86_64 libstdc++-debuginfo-15.2.1-1.fc42.x86_64 rsvg-pixbuf-loader-debuginfo-2.60.0-2.fc42.x86_64 librsvg2-debuginfo-2.60.0-2.fc42.x86_64 libdav1d-debuginfo-1.5.1-1.fc42.x86_64 gdk-pixbuf2-modules-extra-debuginfo-2.42.12-3.fc42.x86_64
(gdb)