From: Phillip Wood Date: Wed, 28 Oct 2026 14:29:19 GMT Subject: Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal Message-ID: <3f939144-d4b3-4bc5-aaea-16422450d638@gmail.com> In-Reply-To: <20261028133755.112476-1-hu2008yinxiang@163.com> On 28/10/2026 13:37, ian4hu wrote: > Hi, > > Gentle ping on this one. It is queued in 'seen' as > iy/sigchain-recover-concurrent-pops, and the latest "What's cooking" > marks it as "Needs review". > > A short recap: when two copies of the same signal reach two threads > nearly at the same time, the concurrent sigchain_pop() calls in the > handlers can unwind the chain by two levels instead of one, leaving > the process spinning in a handler that keeps re-raising the signal. It sounds to me like the bug is that we're unwinding the same chain of signal handlers in two different threads at the same time. Doesn't that mean we're potentially calling the same handler twice, once from each thread, which doesn't sound like it'll lead to anything good. I wonder how hard it would be to fix the code to ensure that signals are blocked when we spawn a new thread so that they are only handled in a single thread. It would probably be good idea to start using sigaction() as well so that we don't interrupt a signal handler if we receive another instance of the same signal while the handler is running. Thanks Phillip > This is reachable with "git clone --depth 1" over ssh receiving two > SIGTERMs in quick succession, and only SIGKILL gets rid of the > process. > > The patch leaves the push/pop fast path alone and only teaches the > "n < 1" guard in sigchain_pop() to fall back to the pre-chain > disposition, so the stuck handler's raise() terminates the process > just as a single delivery would. > > Peff, I have Cc'ed you since you wrote the sigchain code. I would > appreciate your thoughts on whether this "repair after the fact" > approach is acceptable, or whether you would rather see the chain > mutation serialized instead. I also have a version that uses a > per-signal spinlock around push/pop, and can send it if that is > preferred. > > Thanks, > ian4hu