From: Phillip Wood <phillip.wood123@gmail.com>
To: ian4hu <hu2008yinxiang@163.com>
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
phillip.wood@dunelm.org.uk
Subject: Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal
Date: Thu, 29 Oct 2026 11:15:05 +0000 [thread overview]
Message-ID: <d18d98c9-08a7-48e1-8a6b-a43aed05dec8@gmail.com> (raw)
In-Reply-To: <0806471f-957a-4f32-ac33-c00c25a46033@gmail.com>
A couple more thoughts ...
On 28/10/2026 16:39, Phillip Wood wrote:
> On 28/10/2026 14:47, ian4hu wrote:
>>
>> If you prefer the thread-level fix, I am happy to build it: a
>> git_pthread_create() wrapper that blocks SIGINT/SIGHUP/SIGTERM/
>> SIGQUIT around pthread_create()
>
> I think that is probably the safest solution (though it does not help
> for threads created external library code - I'm not sure if we have any
> instances of that). I'd be interested to hear what others think, so I'd
> wait a couple of days to see if anyone else comments before spending
> much time on it.
We have a number of places where we spin up a bunch of threads to
parallelize some work, for example in preload_index() we create some
threads in a loop to read the index. In cases like that, where the loop
body is just setting up some per-thread data and creating a thread, it
would be more efficient to block signals before the loop and unblock
them after, rather than blocking and unblocking each time we create a
thread.
>> - leaving SIGPIPE alone, since it is
>> a synchronous signal and blocking it in workers turns deaths into
>> EPIPE
>
> Does it? I thought that happened when its disposition is set to SIG_IGN.
> Blocking a signal delays its delivery until it is unblocked, it does not
> ignore the signal.
To clarify, in a multi threaded process the delivery of the signal is
only delayed if it is blocked in all threads. If there's one or more
threads where the signal isn't blocked it will be delivered to one of
those threads.
Thanks
Phillip
>> - plus a sigaction()-based chain that masks all signals while
>> a handler runs.
>
> When I wrote my last email I was thinking about blocking the signal that
> is being handled as sigaction() defers the signal that is being handled
> unless SA_NODEFER is passed. However, sigchain_push_common() sets the
> same handler for all the common signals so it is probably safer to block
> at least those as well as I'm not sure all our handlers are reentrant.
>
>> I would then drop this patch, or keep it as a
>> separate last-resort series if you think the belt and braces are
>> worth it.
>
> I'd be inclined to drop it - if we're handling signals in a single
> thread that should avoid the issue.
>
> Thanks
>
> Phillip
next prev parent reply other threads:[~2026-10-29 11:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 12:37 [PATCH] sigchain: recover from concurrent double-pops of the same signal Ian Hu via GitGitGadget
2026-10-28 13:37 ` ian4hu
2026-10-28 14:29 ` Phillip Wood
2026-10-28 14:47 ` ian4hu
2026-10-28 16:39 ` Phillip Wood
2026-10-29 11:15 ` Phillip Wood [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-29 14:13 ian4hu
2026-10-29 14:15 ian4hu
2026-10-29 16:03 ` Phillip Wood
2026-10-30 8:45 ` Oswald Buddenhagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d18d98c9-08a7-48e1-8a6b-a43aed05dec8@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hu2008yinxiang@163.com \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.