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

From: Spencer Baugh <[email-masked]>
Date: Wed, 03 Sep 2025 12:03:42 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Spencer Baugh <[email-masked]>
>> Cc: Zhengyi Fu <[email-masked]>,  [email-masked],  [email-masked]
>> Date: Wed, 03 Sep 2025 11:00:19 -0400
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> >> From: Zhengyi Fu <[email-masked]>
>> >> Cc: [email-masked],  [email-masked],  [email-masked]
>> >> Date: Wed, 03 Sep 2025 22:42:26 +0800
>> >> 
>> >> Eli Zaretskii <[email-masked]> writes:
>> >> 
>> >> > Zhengyi Fu, can you please apply it to the current master, and see if
>> >> > it solves the original problem?
>> >> 
>> >> It does resolve my original problem.
>> >
>> > Thanks for testing.
>> >
>> >> But I think we need to call set_proc_thread when the server process
>> >> is not locked as well.  Otherwise the `thread' member of the
>> >> fd_callback_info may still be a dangling pointer.
>> >
>> > Oh, you mean the below?  I agree, it is safer.
>> 
>> We should not do that - if the thread member of fd_callback_info is a
>> dangling pointer, that indicates there's a bug elsewhere.
>
> So how about adding an assertion before we clear it?

Sure.  fd_callback_info.thread specifically should always be NULL at the
time we're using the fd_callback_info slot for some new fd, so we should
assert that.