ryanofsky
commented at 7:14 pm on September 30, 2025:
contributor
Signal m_tip_block_cv when Ctrl-C is pressed or SIGTERM is received, the same way it is currently signaled when the stop RPC is called. This lets RPC calls like waitforblockheight and IPC calls like waitTipChanged be interrupted, instead of waiting for their original timeouts and delaying shutdown.
This issue was reported by plebhash in #33463. These hangs have been present since #30409. A similar bug was also fixed previously in Qt in #18452 and this PR simplifies that fix.
test: Test SIGTERM handling during waitforblockheight call
Currently when CTRL-C is pressed and there is an active `waitforblockheight`,
or `waitforblock`, or `waitfornewblock` RPC call, or a mining interface
`waitTipChanged` IPC call with a long timeout, the node will not shut down
right away, and will wait for the timeout to be reached before exiting.
This behavior is not ideal and only happens when the node is stopped with
CTRL-C or SIGTERM. When the node is stopped with `bitcoin-cli stop`, the wait
calls are interrupted and the node does shut down right away.
The next commit improves node behavior. This commit just adds test coverage to
simplify the next commit and clarify the change in behavior there.
6a29f79006
DrahtBot
commented at 7:15 pm on September 30, 2025:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
Conflicts
Reviewers, this pull request conflicts with the following ones:
#29770 (index: Check all necessary block data is available before starting to sync by fjahr)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
ryanofsky
commented at 3:12 pm on October 1, 2025:
contributor
They seem to show py -3 test_runner.py being called, and this just with failing with no output after around 10 minutes, with CI reporting Process completed with exit code -1073741510. where -1073741510 is 0xc000013a or STATUS_CONTROL_C_EXIT. So it seems like sending ctrl-c to the node might be killing the whole test?
EDIT: Turns out this is expected, the test needs to start the node with creationflags=subprocess.CREATE_NEW_PROCESS_GROUP on windows, otherwise ctrl-c does kill all processes.
init: Signal m_tip_block_cv on Ctrl-C
Signal m_tip_block_cv when Ctrl-C is pressed or SIGTERM is received, the same
way it is currently signalled when the `stop` RPC is called. This lets RPC
calls like `waitforblockheight` and IPC calls like `waitTipChanged` be
interrupted, instead of waiting for their original timeouts and delaying
shutdown.
Historical notes:
- The behavior where `stop` RPC signals `m_tip_block_cv`, but CTRL-C does not,
has been around since the condition variable was introduced in #30409
(7eccdaf16081d6f624c4dc21df75b0474e049d2b).
- The signaling was later moved without changing behavior in #30967
(5ca28ef28bcca1775ff49921fc2528d9439b71ab). This commit moves it again to
the Interrupt() function, which is probably the place it should have been
added initially, so it works for Ctrl-C shutdowns as well as `stop`
shutdowns.
- A Qt shutdown bug calling wait methods was fixed previously in #18452
(da73f1513a637a9f347b64de66564d6cdb2541f8), and this change updates that
fix to avoid the hang happening again in Qt.
c25a5e670b
ryanofsky force-pushed
on Oct 1, 2025
ryanofsky
commented at 5:36 pm on October 1, 2025:
contributor
Updated 4ee8e2248e54a33f0a3a2e808d46a7b0b8ea7bc3 -> 68cad90dace40f7a015ca4ff81b878fc8fdc1dd5 (pr/sigwait.1 -> pr/sigwait.2, compare) to fix CI failures, also added more documentation and explanation in commit description
ryanofsky renamed this:
init: Signal m_tip_block_cv on Ctrl-C
init: Fix Ctrl-C shutdown hangs during wait calls
on Oct 1, 2025
TheCharlatan approved
TheCharlatan
commented at 8:55 pm on October 1, 2025:
contributor
ACK68cad90dace40f7a015ca4ff81b878fc8fdc1dd5
This should be backported in my opinion.
Sjors
commented at 8:45 am on October 2, 2025:
member
ACK68cad90dace40f7a015ca4ff81b878fc8fdc1dd5 (see below)
Sjors
commented at 9:57 am on October 2, 2025:
member
Mmm, the GUI experience is less great (testnet4, ctrl + c from the terminal where I launched it):
This seems to stay stuck.
Doesn’t happen on the first commit, so might be a regression.
ryanofsky
commented at 10:19 am on October 2, 2025:
contributor
Mmm, the GUI experience is less great (testnet4, ctrl + c from the terminal where I launched it):
[…]
Doesn’t happen on the first commit, so might be a regression.
Oh, thanks for testing. That does sound like a regression. Will mark as draft until this is debugged
ryanofsky marked this as a draft
on Oct 2, 2025
fanquake
commented at 3:30 pm on October 2, 2025:
member
This should be backported in my opinion.
Not going to block 30.0 if it’s not ready, but marked for backport.
fanquake added the label
Needs backport (30.x)
on Oct 2, 2025
luke-jr referenced this in commit
e4713ff8f9
on Oct 2, 2025
luke-jr referenced this in commit
663bc960f5
on Oct 2, 2025
ryanofsky force-pushed
on Oct 3, 2025
ryanofsky
commented at 8:46 pm on October 3, 2025:
contributor
Updated 68cad90dace40f7a015ca4ff81b878fc8fdc1dd5 -> c25a5e670b27d3b6eb958ce437dbe89678bd1511 (pr/sigwait.2 -> pr/sigwait.3, compare) fixing regression in previous version that caused Qt shutdown to hang during wait calls from the GUI console
ryanofsky marked this as ready for review
on Oct 3, 2025
Sjors
commented at 9:08 am on October 4, 2025:
member
tACKc25a5e670b27d3b6eb958ce437dbe89678bd1511
It’s also a nice simplification.
DrahtBot requested review from TheCharlatan
on Oct 4, 2025
TheCharlatan approved
TheCharlatan
commented at 9:47 am on October 5, 2025:
contributor
Thanks for the fix, makes sense to call Interrupt earlier in the shutdown sequence.
ACKc25a5e670b27d3b6eb958ce437dbe89678bd1511
fanquake added this to the milestone 30.1
on Oct 8, 2025
enirox001
commented at 9:08 pm on October 11, 2025:
contributor
Concept ACKc25a5e6
Replicated the issue; fix works. Good refactor in init and interfaces for interrupt support.
regtest: RPC interrupts immediately on shutdown signal.
testnet: RPC does not interrupt and waits for timeout.
Tested on Linux with Ctrl+C to trigger the signal interruption.
Please clarify testnet behavior.
TheCharlatan
commented at 12:07 pm on October 31, 2025:
contributor
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2025-12-12 03:13 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me