Article View: linux.kernel.git
Article #1820Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal
From: ian4hu
Date: Thu, 29 Oct 2026 14:13
Date: Thu, 29 Oct 2026 14:13
56 lines
10479 bytes
10479 bytes
Hi Phillip,
Thanks for the follow-up. All three points make sense; let me
confirm what I plan to do so we are on the same page.
On SIGPIPE: you are right that my wording was wrong. Blocking is
not ignoring, and the write() fails with EPIPE either way. What
changes is that the signal is not delivered while it is blocked;
and since a SIGPIPE raised by a write is thread-directed, it stays
pending on the writing thread instead of being picked up by the
main thread. If that thread never unblocks it, it is never
delivered, so a worker that blocks SIGPIPE simply stops dying of
it. I left SIGPIPE out precisely to keep the "upstream of a pipe
dies of SIGPIPE" behaviour that common-init.c restores. The set I
plan to block is SIGINT, SIGHUP, SIGTERM and SIGQUIT. If you
think SIGPIPE belongs in it too, I will add it.
On the blocking pattern: agreed. I will block once around the
spawn loop and restore before the join loop, rather than around
each pthread_create(), via a small guard pair
struct signal_mask_guard guard;
block_sigchain_signals(&guard);
for (i = 0; i < nr_threads; i++)
pthread_create(&t[i], NULL, fn, &data[i]);
restore_sigchain_signals(&guard);
plus a git_pthread_create() wrapper on top for the single-thread
call sites. The loops I have in mind are preload_index(),
index-pack, pack-objects, grep, name-hash and the read-cache entry
loader; the fsmonitor--daemon and simple-ipc threads I would leave
alone for now, as they have their own lifecycle and signal
handling.
On sigaction: agreed as well. The handled signal is deferred by
default, so the remaining hole is a handler being interrupted by
one of the other common signals that share the same handler. I
will set sa_mask to sigfillset() and save/restore the whole
struct sigaction, so pop() does not clobber the caller's
sa_flags/sa_mask.
The one gap I cannot close is a thread created by library code
rather than by us. libcurl's threaded resolver is the case I am
aware of, depending on how libcurl is built; I do not know of an
in-tree instance, and I will mention it in the cover letter rather
than claim it is covered.
So I will drop this patch and build the series along those lines.
As you suggested, I will wait a few days for Peff and Junio to
comment before spending much time on it; if nobody objects I will
send the replacement as v2.
Thanks,
ian4hu
Technical Details
Message-ID:
<20261029141308.163936-1-hu2008yinxiang@163.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73773-linux-kernel-git=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73773-linux-kernel-git=dewy.ru From: hu2008yinxiang@163.com (ian4hu) Newsgroups: linux.kernel.git Subject: Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal Date: Thu, 29 Oct 2026 22:13:08 +0800 Organization: Usenet Network Message-ID: <20261029141308.163936-1-hu2008yinxiang@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2024603"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+hK/4xQ2s9q/k5WtHqgL9RaZJV0= sha256:J+pEcr2EdVCLuwoDOTdRo9ckJfqoq8V+NfIp1pVLs70= sha1:O9sXgJbdL7dJQFs9idq9K6PiO/M= sha256:S1F+ANG4ot0Z9rGhM9GlNTRCNNpxLbobMC2xv3Zo0os= List-ID: <git.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 896E7125C69; Thu, 29 Oct 2026 17:20:58 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.947 X-Spam-Status: No, score=-1.947 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A4M5FBu5TEQ6; Thu, 29 Oct 2026 17:20:51 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-73773-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id C211E125C68; Thu, 29 Oct 2026 17:20:41 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id E141228E9A; Thu, 29 Oct 2026 14:13:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1793283232; b=UhSUIqgOMzJNy8FmKJXM2RANJazIpGZuaYokz7u3653Myo5ibDyzLjxJaJwHYHv/7Q/L uHsU5XVlTUDK5NK730KFR9rbTzBC3o9hUVVhCqR/qX6WS/sTgs5pWhOpfi8tU/OjT2o8t /dCJJK+CVtXYbZZvnnnPKXogQWRyTmxoMqtoNFK7S5oZ4BFYC2QjyDllztEJf6ZRQgbjY rLX/Dm2oReZvZe1rIB7TPrOX9Em6foN3e6QX7IB8ZvDfDa1eQF+JlDxH8+M1XauXCtoZT UNSP+2Tq6Ffu9Si+l7PhM62XUYWGWn7/OiYcquZJJL5BMDD/kxiGdAlgQdBT2mPferg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793283232; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=rI9Nl1ZRlvvzhtH0grSrahQNCseoQcwaGaA4H0SzSag=; b=np80VUUF0CckeDLCm1jQTMkYR5tDWi6GSgTuBfgHAw2sAE0FxbMz+YnPNnoXg2YMzI0o m8vxD42sl/V6WaAkrTt4kqqpoojoH6tFnqYHr4vZBQr/49ODGIOHz/ZoIiK4ErCjqsyoI OF1aKQwgRsqRMIl2Hn0f86zJ5pEn/WWhhJUxtaZGVUqrobG2qyP7TTMM2WyZzlqQogyzQ b9b0LWAwTDAc60rhZ11vG4b6XAW4p12CAk7LWXXizvVgcOECCCyOUBidgyyiL1FotCP0m UNCf7ebS/8p204CG2Qi4MuS3rQBPj6cXMD692QncDH1NG2UE9DT9gtZGeqb/ZH0uGDw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=NLlaIPhN; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=fail smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB824606A31D; Thu, 29 Oct 2026 14:13:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=NLlaIPhN X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.4 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793283231; b=ol/iulbN6OS2CaqehznAcZCL74AsnXM8KCNPC3FrU3Wv07mO0nJUiLyNEFvNnVqqDJB7 I+PMkfh8tTxQEMr/wC95vNd2kaTeqTdcwcg55C8UGocjLthlFXpaDWuu7ayKrt12h93nw WXbXNgfD0i+1mKJEAYGr64iPCewdzS66t+GbKO9EvHrAJfANyJaLVlr1X41dDR3BmNs69 XujC3oJhQFfORInVny5VOdSOtV6JqW2mZHMC5DrSN2OX+ypCEvg8XIfOPpsAv6VSTXKNN lYrol1mPJ1gYUmyCsYMgAsddsUk+9lyH0xE1H0BZDmaoeefOnLdOdHwgB37hPxWk2Hg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793283231; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=rI9Nl1ZRlvvzhtH0grSrahQNCseoQcwaGaA4H0SzSag=; b=3LBYQCRwXJ++Isll2oy9RrfDjCyHWomQvhaAke/+UZ3j2GuSNTYMtzHyxT+ZZ1NNMFbE e3AYJdtymAjcoOps0DuJYAh9sjBxincDqyNlgh3m6w9Z7+E9Q+O3VSVa65Kf2gCRDGILp NDKXQJm/xbooaOcSSOtoFywlsTsIObtkI6kiY4OMY/L9R+CDrHvpZeFMbK5OUSKnlGaeJ 81O5QI1FthBOemYQMC4KRv0OvuLnz4xXwvPXkziDa+ZaRn/ZJv9/AkhtfaZWUvyRO/y3j qfv2C7RopL3cnRGcfPMHaVgFBzU7pb31cibGGjRkOjAC3Jx8OFQZlY4B1yUsK0U/55g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=none smtp.remote-ip=220.197.31.4 X-Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D94EC606A31E for <git@vger.kernel.org>; Thu, 29 Oct 2026 14:13:48 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D94EC606A31E X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=rI 9Nl1ZRlvvzhtH0grSrahQNCseoQcwaGaA4H0SzSag=; b=NLlaIPhNlTrZwaVpTH 8kuJ6RmAXT0NpsVzQIy5ervU2eRStGl8dWCe8XpIjEGeOn5JCdm12+Sx0Wyro+Fk lA+0dQP98RLdbBptCDDwElSQichYJetX8+upwUoKQBU2URyOjrByDsaPTWR379z8 vykUD+OtXkMa8xqGokk8MDiVA= X-Received: from mbp-home.softshell-mine.ts.net (unknown []) by gzsmtp5 (Coremail) with SMTP id QCgvCgB3ppt0VONq9KUpCw--.34562S2; Thu, 29 Oct 2026 22:13:08 +0800 (CST) X-Cc: git@vger.kernel.org, gitster@pobox.com, hu2008yinxiang@163.com, peff@peff.net, phillip.wood@dunelm.org.uk X-Mailer: git-send-email 2.53.0 X-Mailing-List: git@vger.kernel.org X-List-Post: <mailto:git@vger.kernel.org> X-List-Help: <mailto:git+help@vger.kernel.org> X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:git+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: QCgvCgB3ppt0VONq9KUpCw--.34562S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zr47Xr13GFyrJF15tF13urg_yoW8KrWkpF Z0qr1qyrZ7GFyxuFyDZa18GF4fArZ3uFs8Gr98G348A3y5Ww4SkrySya1YvFW5Ars7W3Wj vFsY934DJFWDtaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRpBTbUUUUU= X-CM-SenderInfo: dkxsiigy1l05pldqwqqrwthudrp/xtbC7RXFX2rjVHU+mwAA3v