mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
Quitting or unloading a wallet while an Activity list is still applying a wallet change crashes the app with SIGSEGV #1116
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#1116
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?
If the app is asked to quit while an open wallet's Activity list has a transaction change it has not laid out yet, and that list is not the page on screen, it dies with a segmentation fault and the node skips its clean shutdown. On a large wallet, in a window that is being drawn, that state lasts several seconds. The same crash is reached without a quit when a wallet in that state is unloaded; the details are in this comment.
To reproduce:
The process exits with SIGSEGV.
debug.loghas noShutdown doneand stderr is empty.With that wallet's Activity tab showing, the quit is clean. The list on screen is spared; the list that crashes is one that is not on screen. That can also be the list of a second open wallet: in the rows below without "one wallet", two wallets were open, the payment went from one to the other and blocks were mined to the sender, with the recipient's Activity showing. The sender's list is the one that crashed.
qt6Every quit route behaved the same, 5 of 5 each offscreen and native: the application quit event, closing the window, RPC
stop, and SIGTERM. The same matrix on6e54a48ab571gave the same pattern.Crash reports show the main thread in:
That is
EXC_BAD_ACCESSat address 0x8, reached from the deferred delete of a page.On shutdown the main window clears its page stack (MainWindow.qml#L310-L313). The Activity list uses section delegates (ActivityListPage.qml#L346-L348). When the stack is destroyed while a list that is not on screen still has a model change to lay out, Qt updates its sections against a context that is already gone. I inferred the link to
main.clear()from the trace; I did not confirm it with a debugger. The same frames appear in KDE bug 500579 on Qt 6.8.2, so the weakness is in Qt, and the app can avoid triggering it.After a crash the app restarted normally: wallets, the saved request and the payment were intact.
mempool.dathad not been written. When the crash followed a confirming block, the node came back one block lower, as it also did after a SIGKILL control. I did not measure the cost of that on a long-running node.#990 at
389e2f1dac5cshortens the freeze to 0.3 to 0.6 s, and a quit 2 s after a payment on the 5,000-transaction wallet was clean there, 0 of 5 against 3 of 3 on its base, offscreen. It does not change the crash where the window is not drawn: minimized, a quit crashed 10 of 10 and an unload 15 of 15, as on the base, and a quit within 5 ms of a payment crashed 14 of 34. The numbers are in my comment there. The freeze itself is the label scan in #974.Suggested: stop a wallet's views from applying model changes before they are destroyed, for example by detaching the list's model or section delegate before the page stack is cleared at shutdown and before a wallet's view is dropped on unload. Keeping the stack alive until node shutdown has finished would cover the quit only.
Reproduced on merged
qt6ateed1f426fcb6and at6e54a48ab571, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen and native. Payments and blocks came over RPC; except in the one-wallet rows, the paying wallet was open in the same app. The quit event and window close were sent through the test bridge; no physical Cmd+Q or menu click was used. macOS wrote crash reports for 8 of 214 crashes, all with the same frames; the other cells rest on exit code -11 and the same last log line.This has no time limit while the window is not being drawn, and a small wallet is enough.
A window that is minimized, hidden or completely covered by another window lays nothing out, so a change that arrives then stays pending until the window is shown again. A quit in that state crashes if the changed wallet's Activity list is not the page on screen.
At
2bd5a61e8304, native window, 30-transaction wallet, payment sent from outside the app so that exactly one open wallet changes, window minimized or hidden first, quit 10 to 30 s later:With a payment between two open wallets it was 101 of 101, with waits from 5 s to 600 s before the quit.
Without minimizing, Receive showing, quit 15 s after the payment:
So a node started with one wallet and left on its start page, then minimized, hidden or left completely covered by other windows, crashes on quit once a payment or a confirmation has arrived, unless its window is brought forward first. Nothing in the wallet has to be opened. One frame is enough to clear the state: in the one covered launch where the window was exposed for a moment before the quit, the quit was clean.
One case where a crash did cost something: a legacy wallet update in progress. With a second open wallet in the crashing state, Quit during Update wallet crashed 7 of 7, before the node was told to shut down, so the update was neither finished nor rolled back. The wallet was left half-converted: it would not open, a second update was refused as "already a descriptor wallet", and the backup could not be imported (#629). Copying the
.legacy.bakoverwallet.datby hand restored it. Without the crashing state the same quit was clean, 6 of 6, and the original wallet was restored. That roll back is what Core does when the wallet is behind the chain tip; a wallet at the tip keeps the finished update after a clean quit (3 of 3 each way, offscreen, with a 15,000-key wallet written by Bitcoin Core 29.0). The crash runs used a hand-built 60,001-key legacy wallet, whose update lasted tens of seconds. With the 29.0 wallet I repeated only the kill, withbitcoindalone: it leaves the same half-converted state, 6 of 6.The application quit event and SIGTERM behaved the same. Each crash exits with SIGSEGV and
debug.loghas noShutdown done.eed1f426fcb6gave the same split, 8 of 8 against 0 of 5.Limits:
showMinimized(),hide()andraise()calls made through the test bridge, and the cover was a second app window. I did not use the yellow button, Cmd+M, the Dock or the tray menu, no physical Cmd+Q, and nothing was checked on a screen.The same crash can be reached without quitting: unloading a wallet in this state kills the app.
When a wallet is unloaded or closed, its view is destroyed while the app keeps running, and that takes the same Qt path as the page stack at quit. If that wallet's Activity list holds a change that no frame has laid out, and the list is not the page on screen, the app exits with SIGSEGV. With
bitcoin-cli unloadwalletit was gone 0.05 to 0.15 s after the call.debug.logends atReleasing wallet, the node is not shut down, and the other open wallets go down with it.At
2bd5a61e8304, native window, wallet A open and not showing its Activity list, window minimized, one payment to A from a wallet that is not open in the app, thenbitcoin-cli unloadwallet A1 to 3 s later:unloadwallet30 s / 120 s after the paymentWhat counts is the number of rows in the list when the change arrives, not their dates. A single row is spared at quit as well: with a quit in place of the unload it was 0 of 4 with one transaction against 3 of 4 with two. I do not know why. The list also has to have been laid out once since the wallet was opened: in 3 launches where the window had never been drawn, the unload was clean.
A window that is shown but not drawn behaves like a minimized one. In 7 launches the window was shown and not active, a read through the test bridge showed the change still not laid out after 2 s, and
unloadwalletcrashed 7 of 7. I take it the window was behind other windows.The app's own Close wallet takes the same path, but I only got there with clicks delivered through the test bridge to a window that was not drawn: 3 of 3 minimized, 3 of 3 hidden, 0 of 2 without a payment. After the window was restored the change was laid out within 0.03 to 0.6 s, and Close wallet was then clean, 12 of 12. So I could not produce it the way a person would click.
DesktopWallets.qmlkeeps oneWalletViewper open wallet in aRepeaterand drops the view as soon as the wallet becomes unavailable (DesktopWallets.qml#L46-L56, #L444-L470). Each view owns that wallet's ActivityStackView(WalletView.qml#L180-L190). Two crash reports from these launches have the four frames above,setSectionHelpertoupdateSections, at address 0x8 under~QQuickStackElementand~QQuickStackView. Below them is the deferred delete of the wallet's view insideQCoreApplication::exec(), notmain.clear(). So keeping the stack alive until node shutdown has finished would not cover this route. Detaching the list's model or section delegate before a wallet's view is destroyed would cover both.eed1f426fcb6behaved the same, 1 of 1.Limits:
unloadwalletwas sent withbitcoin-cli, which needs the RPC server. That is off by default in the app. I did not try the app's own console.