mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:03:39 +00:00
RPC console: keep stop and command metadata off the GUI thread #964
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml#964
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #920.
Ordinary RPC commands already run in the background, but the console's literal
stophandler enters the RPC dispatcher on the GUI thread. That path can acquire backend locks. Command-completion metadata is also fetched from the backend during GUI setup. These are source-confirmed paths; no long console stall was measured.Keep shutdown control asynchronous and usable while an ordinary RPC command is blocked. Do not put the operation needed to release a blocked command behind that command. Fetch command metadata outside the GUI thread and publish a cached completion list.
Preserve command parsing, history, selected-wallet routing and help behavior. Show pending work and errors where needed. Ignore late replies after shutdown starts and retain the backend until pending calls finish. Coordinate console retirement with application shutdown under #917.
Test a blocked RPC followed by stop, metadata loading, wallet routing and shutdown with pending replies. Verify continued GUI event processing and safe destruction. Large-output rendering under #828 is a separate concern.
The synchronous
stoppath also aborts the app when it runs before Core has finished starting.To reproduce:
-keypool=100000, which held "Loading wallet…" for about 35 s.stopand press Enter.The process dies at once with SIGABRT. stderr ends with
libc++abi: terminating due to uncaught exception of type UniValue, anddebug.loghas noShutdown done. This happened on 3 of 3 offscreen runs and 1 of 1 native run.Controls during the same startup:
getblockcount,help,STOPandstop 1each add one error row,Loading wallet… (code -28), and the app stays up.Shutdown done.stopafter startup has finished exits 0.The literal
stopis executed on the calling thread with notry/catch(rpcconsolemodel.cpp#L350-L354). Core's dispatcher throwsRPC_IN_WARMUPuntil initialization completes (server.cpp#L858-L865). The worker used for every other command catches that error and turns it into a row (rpcconsolemodel.cpp#L246-L260). Bitcoin-Qt makes the same unguarded call (rpcconsole.cpp#L1020-L1022), but by source its window is not shown until startup has finished. Here the shell and the console are usable during startup.#985 at
3d03beb1d931replaces this call with a shutdown request (rpcconsolemodel.cpp#L369-L372), which removes the throw. I have not run that branch. A test that submitsstopbefore initialization completes would cover this case.The observed cost was an unclean exit and an OS crash report. Relaunching the same data directory started normally.
Reproduced on merged
qt6ateed1f426fcb6, macOS / Qt 6.9, isolated regtest, offscreen and native. The command was submitted by calling the Enter handler's function through the test bridge, not with a physical Return key. The startup window was lengthened artificially; I did not measure it on a real mainnet node.