Article View: linux.kernel.git
Article #1740Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal
From: ian4hu
Date: Wed, 28 Oct 2026 14:47
Date: Wed, 28 Oct 2026 14:47
56 lines
10973 bytes
10973 bytes
Hi Phillip,
Thanks for the review. I agree with both halves of your mail, and
I think the difference between the two approaches is worth spelling
out.
What I sent only repairs the aftermath. It leaves the corrupted
state reachable and merely turns the wedge into the normal death, so
it is small and inert on the legitimate paths, but it is a band-aid
and, frankly, a bit dirty: it heals a state that should never have
been entered, and by the time it heals it the two threads have
already run the handler's close()/unlink() cleanup concurrently.
I did first try the serializing route. My earlier attempt
(https://github.com/gitgitgadget/git/pull/2262, never sent to the
list) took a per-signal spinlock around the push/pop update, with
the signal blocked while the lock is held. That keeps
signals[sig].n and the installed disposition consistent under any
interleaving, so the corrupt state cannot be constructed at all,
and it also protects sigchain_push/pop called from worker threads.
I dropped it because of the edges:
- two threads can still run the handler body concurrently; the
lock only makes the unwind atomic, it does not serialize the
cleanup itself;
- the POSIX corner is awkward: sigprocmask() is unspecified in a
multithreaded process, pthread_sigmask() is not
async-signal-safe, and taking the lock in a handler needs one
of them;
- a thread that dies inside the critical section leaves the lock
held and the next delivery spins forever, trading a hang for a
hang;
- the Windows branch needs its own InterlockedExchange path that
cannot be exercised in CI here.
So the question I would like your guidance on: do you consider a
locked/serialized chain a complete fix for what you described, or
does this have to be prevented at the thread level - block the
signals when a thread is spawned, and use sigaction() for the
chain? My own reading is that serializing is a complete fix for
the chain state but not for the handler bodies, so if the latter is
what you want, your suggestion is the way to go and the lock does
not buy much beyond it.
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() - leaving SIGPIPE alone, since it is
a synchronous signal and blocking it in workers turns deaths into
EPIPE - plus a sigaction()-based chain that masks all signals while
a handler runs. 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.
Thanks,
ian4hu
Technical Details
Message-ID:
<20261028144736.121433-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-73661-linux-kernel-git=dewy.ruReferences:
<3f939144-d4b3-4bc5-aaea-16422450d638@gmail.com>Show 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-73661-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: Wed, 28 Oct 2026 22:47:35 +0800 Organization: Usenet Network Message-ID: <20261028144736.121433-1-hu2008yinxiang@163.com> References: <3f939144-d4b3-4bc5-aaea-16422450d638@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1791918"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:DBkAWbbb7EftgqkfMMcceHOx9so= sha256:++2rz7GpYLNtogTYDTXSrbwaDSmcxz/EGBXjg4bxM2A= sha1:hAOREf0DoEBVy1mQSvTYv3ExXAk= sha256:xyBlXV57Y/kFJUWoRQW2OxlVjrh8DBT/MU1HV/M3WcY= 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 E8921125C37; Wed, 28 Oct 2026 17:50:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.047 X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31 tests=[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 Znjw3PvK-EJk; Wed, 28 Oct 2026 17:50:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-73661-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B63F7125C32; Wed, 28 Oct 2026 17:50:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id A4EF129263; Wed, 28 Oct 2026 14:48:23 +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=1793198903; b=xWBRjmzo30O5VwUwyibFundj3Uxe2opvQwaN1Xw9/74U8wYCfJaLpYEz9pe9xw4gwfXd N/JTMyUuZY1qEJTZWDYAF1UD8XFZvctlVij+w4eVO17eFzUwJ0GEAQY6oPDH1EnwJtCgM qUdVvd9ZxEEvCdHN1HIIuFD8g/ItCGiORQeNHFtGVYRlcAbJYVvZhruei4MKN6AKDheVV zdplCD6omaGhk4Dg6IMUdXANTBoEhLcHpEMYcGrMm+eFZl4LxLcDYH45G643dLe/2OP7l 4QLuIrC4vV727tiT5EXOlpiOqTOHHM9EvIcNzfRqw3Vr2eCmkCbQl75TNNS2Pdd1JfQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793198903; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: 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=34X3XmbEV734Bn1cc+Pc8mXOnWqX/WEBVu8zSTx/uK8=; b=0ML6xCATlrn3F3sSIc3/Z+sR160qqbcVwzJUB2Zo9RufKthfpf+6WUeldHqCzDZRAb+c QMChOoDpq8XDUDOVeHs1qjqZeWlseOu7qLgARcLlA/JzmjAn6rtelCXQmHfniYzd1tQsV kKpOrZ1UGR40JwMNnKoke8gVK5xxkdVeeOC8lVPZXC4x4jS+l5CMncTfBzXvgCj5qIGCV NFtP1SR/ZVWodL9A6xhlL7nELPOKRdP7awVe+FlGsMXF3aA4TfhDAgDXKJm8+XpL6HcCe VpHZctDcAtqE/5zZzdboyi9FlF0CcM8js3qYpGV8nmz3fG85V3gQUMVKR0F9ij+q7Fg== 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=GPSLk0ut; 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 1808D606A323; Wed, 28 Oct 2026 14:48:23 +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=GPSLk0ut 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=1793198902; b=gdjzjLvgryJBMlAURstag8n5dymbb6kkVguUliHQKxRmjwrv4YYxaNxUu85wVYOxq4wr OAxIW/pEaBsiPrU2STEP3qYusOcYlfEha9eZdDhEGXie6U6pBi90e3ERmJGqGUXFpNhEH kFVKF23P46FEjK2kYNuINVoSz/ML9Or1V28yWQcS8EwHGEnjzL9gp0hBeJibpU2Zyr5oS rSWgMH+BxcEoo2tSm9ZnrEakQJg0Ehrb8UoE0DDO5/kZaHLL1nUs8xBzJzu04VKo8wqU8 XXeD7qwoOdt3f08UN6iPnUbolkBLNfglitDlPqTwIOfakk11gcL2kfVe4ShziIIGi2g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793198902; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-Originating-IP:X-CM-SenderInfo; bh=34X3XmbEV734Bn1cc+Pc8mXOnWqX/WEBVu8zSTx/uK8=; b=dClUBievOdfTHpfdh7rFk+025IXI+OSB9tH4zwZjXmNnQdLLcV7hs4yxI5cS+SKWgctm IxuKM57FgUFqql1T61qBCj5UYycneSZgIHSCEBIYL6JAsFcOImJHH6DqxXPdMTe4bjtxE o3C1B3VH4SrnTcEJu6/y+bButtR+qdmdi9nZv/e+sY6lQgLzsg6t+CWcXsBhZGQ9T+jS4 9hSt72txcDVhcTYaUZv5toRgPDwz9HdV9IIktuF90ZZHD3dyk+n4fqg2I0sCfuXYu98W8 vTUsY/WHuqg7/WNnUQI/YsNbQKM4KV+R+SVFTca9HJCHpzdAlyYWIqQWP1EbJMvdS6g== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=GPSLk0ut; 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 A6D95606A31E for <git@vger.kernel.org>; Wed, 28 Oct 2026 14:48:19 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A6D95606A31E 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=34 X3XmbEV734Bn1cc+Pc8mXOnWqX/WEBVu8zSTx/uK8=; b=GPSLk0uthYXS9MMsse xGlk/G/K3TBy7vawisemorpbHexqhV0HJaV5XAHioRdovhbUTSCgZOvSGoeySdi6 /GlNydOiXPw+xBJiULcbzKgJX18kakDxuIAXVIFETHu5Y6v+I+iWeAPlCOQ6NaOn 0MTiP0P6xUWGbEG51D/mC9qYs= X-Received: from mbp-home.softshell-mine.ts.net (unknown []) by gzga-smtp-mtada-g0-2 (Coremail) with SMTP id _____wD3f3UIC+JqHJrUDQ--.28271S2; Wed, 28 Oct 2026 22:47:36 +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-In-Reply-To: <3f939144-d4b3-4bc5-aaea-16422450d638@gmail.com> 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: _____wD3f3UIC+JqHJrUDQ--.28271S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxXF18uw17tF17ur1Duw15Jwb_yoW5Gr1DpF Z8Ka4Ykr1kur4vvF9rCw48Ga4rCw48GFWUCry5K3yFv398Wwnakr97ta15Za45Crn3W3Wj vrW0gr98Cw4DtFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0JUw4SOUUUUU= X-CM-SenderInfo: dkxsiigy1l05pldqwqqrwthudrp/xtbC7ggYsWriCwhyNAAA3C