Conversation
I couldn't replicate it locally. Do you have an input that triggers the deadlock case? |
|
I believe this was one of the inputs. |
|
I couldn't replicate it locally. I've run it 200 times and didn't deadlock. |
It turns out that removing the SIGKILL from lightningd/subd.c can cause CLN to deadlock on shutdown, which holds up coverage reporting. We can resolve most of the deadlock cases by closing the subdaemon socket and allowing the subdaemon to gracefully shut down.
Fields are dropped in declaration order, so the first field is dropped before the second. This change ensures our connection to the peer is always closed before we attempt to shut down the target. This only matters for local mode -- when fuzzing in Nyx the snapshot is always restored before the scenario object is dropped anway. In local mode, it avoids a shutdown deadlock for CLN where our open connection prevents CLN from shutting down cleanly until connectd's keepalive ping fails and causes CLN to drop the connection itself.
ed09485 to
6e62dce
Compare
|
Thanks for pushing on this -- it made look harder at what was actually happening, and I think I've come up with a better approach now that avoids
Yeah, sorry. That input reproduces the issue against CLN's master branch, but not the v26.06.6 we have pinned. I have better repro inputs below that work on v26.06.6. There's actually two different deadlocks I ran into: Subdaemon socket deadlockA CLN subdaemon blocks waiting for input from it's connection to lightningd. lightningd blocks waiting for the subdaemon to shut down. Fixed in the first commit by closing the subdaemon socket to allow a graceful shutdown. Repro input: Peer connection socket deadlockA CLN subdaemon blocks waiting for input from its peer connection. lightningd blocks waiting for the subdaemon to shut down. Fixed in the second commit by closing our peer connections with the target before tearing the target down. Repro input: |
It turns out that removing the
SIGKILLfromlightningd/subd.ccan cause CLN to deadlock on shutdown, which holds up coverage reporting. Add theSIGKILLback in, but first attempt to gracefully shutdown by closing the subdaemon socket and waiting 5s for it. The socket close handles most of the deadlock cases while preserving coverage data. The fallbackSIGKILLcauses some coverage data to be lost but prevents coverage runs from deadlocking forever.