macOS: wallet notifications arriving close together can crash the app once the Addresses or View coins page has been opened #1119

Open
opened 2026-11-11 12:54:44 +00:00 by jarolrod · 2 comments
jarolrod commented 2026-11-11 12:54:44 +00:00 (Migrated from github.com)

On macOS, two wallet notifications arriving close together can kill the app once its Addresses page or its View coins page (both under Wallet settings) has been opened and that page's list has rows out of view. On Addresses, address-label changes over RPC do it, and so do incoming payments, a block confirming several of the wallet's payments, and new addresses. On View coins, incoming payments and such a block do it; label changes and new addresses were not tried there. Saving a label in the app by hand does not trigger it.

To reproduce:

  1. Open a wallet with 16 addresses and go to Wallet settings → Addresses. At the default window size most rows are out of view.
  2. From outside the app, run six setlabel calls on that wallet at the same time.

The process exits within about 0.2 s, with nothing about the crash on stderr and an ordinary debug.log. It ends with SIGBUS, or with SIGTRAP when libmalloc reports a corrupted free block.

Case, native window, 16 addresses unless noted Crashed
Six concurrent setlabel calls, default window 4 of 4
Six concurrent setlabel calls, 1180x1100 window 2 of 3
Two concurrent setlabel calls 2 of 4
A single setlabel call 0 of 3
Six concurrent calls with 8 addresses, so the list fits 0 of 3
Six concurrent calls, offscreen platform 0 of 2
Label saved by hand in the app 0 of 18

The crashing thread is the main thread:

QAccessibleQuickItem::role
QAccessibleQuickItem::interface_cast
-[QMacAccessibilityElement initWithId:role:]
QCocoaAccessibility::notifyAccessibilityUpdate
QQuickItemPrivate::setEffectiveVisibleRecur
QQuickItem::~QQuickItem
QQmlIncubator::clear
QQmlDelegateModelPrivate::releaseIncubator
QQmlDelegateModel::handleModelReset
QAbstractItemModel::endResetModel
AddressListModel::refresh

This stack is from the Addresses list. No stack was taken with View coins.

Each label change makes the wallet's address-book notification queue a refresh() of the address model (walletqmlmodel.cpp#L3217-L3221, addresslistmodel.cpp#L64), and every wallet transaction or lock-state notification does the same through balanceChanged (walletqmlmodel.cpp#L3209-L3240, addresslistmodel.cpp#L65). Each refresh resets the whole model. The coins model behind View coins listens to the same notifications and resets itself twice on each (coinslistmodel.cpp#L16-L18, coinslistmodel.cpp#L82-L121). By the stack, a reset that follows closely on another deletes a row delegate that is still being created, and while it is being deleted Qt's macOS accessibility code calls into the half-destroyed item. The faulting code is in Qt 6.9.0; the app supplies the back-to-back resets. #1084 covers what these resets do to an edit in progress and to the list position.

Suggested: coalesce the refreshes, or update rows in place, in both models, so that wallet notifications do not reset a whole list each time.

Open question

I could not settle whether an accessibility client must be running. Qt's Cocoa accessibility layer acts only once something has queried the window's accessibility interface, so in the runs that produced a stack, something had. A window manager that uses that interface was running during the runs in the table. With it closed, six concurrent calls still crashed 2 of 3, with no stack captured. I did not test with VoiceOver.

These also avoided the crash: QSG_RENDER_LOOP=basic (0 of 2), and one run under Guard Malloc.

Reproduced on merged qt6 at eed1f426fcb6, macOS arm64 with Homebrew Qt 6.9.0, isolated regtest. macOS wrote no crash report and a debugger could not attach, so the stacks come from a signal handler preloaded into some of the test launches. Three were captured, two from RPC runs and one from a programmatic save, and they show the crashing thread only. It needs two wallet notifications arriving within a few tens of milliseconds of each other. Label changes from outside the app are one way; incoming payments and blocks are another, and a block or two relayed payments received from a peer are enough.

On macOS, two wallet notifications arriving close together can kill the app once its Addresses page or its View coins page (both under Wallet settings) has been opened and that page's list has rows out of view. On Addresses, address-label changes over RPC do it, and so do incoming payments, a block confirming several of the wallet's payments, and new addresses. On View coins, incoming payments and such a block do it; label changes and new addresses were not tried there. Saving a label in the app by hand does not trigger it. To reproduce: 1. Open a wallet with 16 addresses and go to **Wallet settings → Addresses**. At the default window size most rows are out of view. 2. From outside the app, run six `setlabel` calls on that wallet at the same time. The process exits within about 0.2 s, with nothing about the crash on stderr and an ordinary `debug.log`. It ends with SIGBUS, or with SIGTRAP when libmalloc reports a corrupted free block. | Case, native window, 16 addresses unless noted | Crashed | |---|---| | Six concurrent `setlabel` calls, default window | 4 of 4 | | Six concurrent `setlabel` calls, 1180x1100 window | 2 of 3 | | Two concurrent `setlabel` calls | 2 of 4 | | A single `setlabel` call | 0 of 3 | | Six concurrent calls with 8 addresses, so the list fits | 0 of 3 | | Six concurrent calls, offscreen platform | 0 of 2 | | Label saved by hand in the app | 0 of 18 | The crashing thread is the main thread: ``` QAccessibleQuickItem::role QAccessibleQuickItem::interface_cast -[QMacAccessibilityElement initWithId:role:] QCocoaAccessibility::notifyAccessibilityUpdate QQuickItemPrivate::setEffectiveVisibleRecur QQuickItem::~QQuickItem QQmlIncubator::clear QQmlDelegateModelPrivate::releaseIncubator QQmlDelegateModel::handleModelReset QAbstractItemModel::endResetModel AddressListModel::refresh ``` This stack is from the Addresses list. No stack was taken with View coins. Each label change makes the wallet's address-book notification queue a `refresh()` of the address model ([walletqmlmodel.cpp#L3217-L3221](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/walletqmlmodel.cpp#L3217-L3221), [addresslistmodel.cpp#L64](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/addresslistmodel.cpp#L64)), and every wallet transaction or lock-state notification does the same through `balanceChanged` ([walletqmlmodel.cpp#L3209-L3240](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/walletqmlmodel.cpp#L3209-L3240), [addresslistmodel.cpp#L65](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/addresslistmodel.cpp#L65)). Each refresh resets the whole model. The coins model behind View coins listens to the same notifications and resets itself twice on each ([coinslistmodel.cpp#L16-L18](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/coinslistmodel.cpp#L16-L18), [coinslistmodel.cpp#L82-L121](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/coinslistmodel.cpp#L82-L121)). By the stack, a reset that follows closely on another deletes a row delegate that is still being created, and while it is being deleted Qt's macOS accessibility code calls into the half-destroyed item. The faulting code is in Qt 6.9.0; the app supplies the back-to-back resets. #1084 covers what these resets do to an edit in progress and to the list position. Suggested: coalesce the refreshes, or update rows in place, in both models, so that wallet notifications do not reset a whole list each time. **Open question** I could not settle whether an accessibility client must be running. Qt's Cocoa accessibility layer acts only once something has queried the window's accessibility interface, so in the runs that produced a stack, something had. A window manager that uses that interface was running during the runs in the table. With it closed, six concurrent calls still crashed 2 of 3, with no stack captured. I did not test with VoiceOver. These also avoided the crash: `QSG_RENDER_LOOP=basic` (0 of 2), and one run under Guard Malloc. Reproduced on merged `qt6` at `eed1f426fcb6`, macOS arm64 with Homebrew Qt 6.9.0, isolated regtest. macOS wrote no crash report and a debugger could not attach, so the stacks come from a signal handler preloaded into some of the test launches. Three were captured, two from RPC runs and one from a programmatic save, and they show the crashing thread only. It needs two wallet notifications arriving within a few tens of milliseconds of each other. Label changes from outside the app are one way; incoming payments and blocks are another, and a block or two relayed payments received from a peer are enough.
jarolrod commented 2026-11-13 14:41:59 +00:00 (Migrated from github.com)

This does not need label changes or an outside program. Any two wallet notifications about 10 ms apart do it, the page only has to have been opened, and View coins is affected as well as Addresses.

At 2bd5a61e8304, native window at the default size, 16 unused addresses, Wallet settings → Addresses showing unless noted. Crashed means the process was gone within 0.3 s of the event with SIGBUS or SIGTRAP:

Case Crashed
Nothing happens 0 of 10
One incoming payment 0 of 20
Two incoming payments about 10 ms apart 7 of 10, 7 of 10, 7 of 14
Two incoming payments 50 ms / 200 ms apart 1 of 10 / 0 of 10
20 incoming payments back to back 9 of 10
One block confirming 20 of the wallet's payments / 2 of them 8 of 10 / 3 of 10
20 getnewaddress calls 10 of 10
Addresses opened, then Activity showing: 20 payments / two payments 8 of 10 / 3 of 10
Addresses opened and closed with Back, then 20 payments 0 of 6
Addresses never opened, same events 0 of 60
Offscreen platform 0 of 11

eed1f426fcb6 gave the same: 9 of 10 with 20 payments, 6 of 10 with two.

The same with Wallet settings → View coins in place of Addresses, in launches where Addresses was never opened. Wallet with 20 coins unless noted; about three rows fit at the default window size:

Case Crashed
Nothing happens 0 of 10
One incoming payment 0 of 10
Two incoming payments about 10 ms apart 5 of 10, 6 of 10
20 incoming payments back to back 7 of 10
One block confirming 20 of the wallet's payments / 2 of them 5 of 10 / 3 of 10
View coins opened, then Activity showing: two payments / block confirming two / one payment 1 of 10 / 2 of 10 / 0 of 10
View coins opened and closed with Back: two payments / 20 payments 0 of 10 / 0 of 10
View coins never opened, Activity showing: two payments / 20 payments 0 of 10 / 0 of 10
Wallet with 2 coins, which both fit: 20 payments 0 of 10
Wallet with 4 / 6 / 8 coins: two payments 0 of 8 / 3 of 8 / 2 of 8

eed1f426fcb6: 6 of 10 with 20 payments, 0 of 10 with one.

With a second regtest node on localhost as the app's only peer, holding the paying wallet, so that nothing was sent to the app's own RPC:

Case, delivered by the peer Crashed
View coins showing: the peer mines a block confirming two pending payments 5 of 10
View coins showing: two payments submitted to the peer together and relayed 5 of 10
View coins showing: one payment relayed 0 of 10
View coins showing: peer connected, nothing sent 0 of 5
Addresses showing: the peer mines a block confirming two pending payments 4 of 10

The two relayed payments reached the wallet 5 to 11 ms apart and the two confirmations 4 to 14 ms apart. In the same rounds as the peer table the two-payment case on Addresses, over RPC, crashed 10 of 11. Between two bitcoind nodes with no GUI, two payments submitted to the relaying node up to 2 s apart reached the receiving wallet 5 to 18 ms apart in 11 of 12 tries; submitted 4 s apart they arrived seconds apart in 3 of 3.

The address model refreshes on balanceChanged as well as on the address-book signal, and every wallet transaction emits it, so each payment or confirmation resets the whole list. The coins model is connected to transactionChanged, addressListChanged and balanceChanged and resets twice per call (coinslistmodel.cpp#L16-L18, coinslistmodel.cpp#L82-L121), so each payment or confirmation resets that list four times. Leaving either page by a tab keeps it on the settings stack (WalletSettingsStack.qml#L72-L108), so the list is still there to be reset; Back removes it.

So a wallet with a screenful of unused addresses, or with six or more coins, with Addresses or View coins opened and left by a tab rather than with Back, can die when a block confirms two of its pending payments, or when two payments arrive together.

On the open question: Qt turns its Cocoa accessibility layer on only when another process queries the window, and the faulting frames are behind that check. With the same window manager running throughout, Qt's own log showed the layer active in 13 of 28 launches, and the crash rate followed it: two payments crashed 7 of 10 and 7 of 14 in periods where it was active, 0 of 3 where it mostly was not. I have still not tested with every accessibility client closed, nor with VoiceOver.

#990 at 389e2f1dac5c does not fix this. Run against its base with launches alternating, it crashed 36 of 40 on Addresses against 8 of 28, and 8 of 20 on View coins against 3 of 20; the base ran below its usual rate, so I can't say it is worse, only that it is not better. A burst becomes one reset per worker round and the coins model listens to the same coalesced signal, but the resets are still full, the coins model still resets twice per refresh, and two a round apart remain. The numbers are in my comment there.

Limits:

  • I took no stack for these cases. The link to the trace above rests on the same reset, the same lists, the same timing and the same controls. The Addresses cases ended with SIGBUS or SIGTRAP, the View coins cases with SIGBUS only.
  • Except in the peer table, payments and blocks were sent over RPC to the app's own regtest node. I did not send a payment from the app's Send page.
  • On View coins only payments and blocks were tried: no label changes, no new addresses, and not the coin picker on the Send page.
  • The sets are small and timing-dependent.
  • macOS arm64 / Qt 6.9.0, isolated regtest.
This does not need label changes or an outside program. Any two wallet notifications about 10 ms apart do it, the page only has to have been opened, and **View coins** is affected as well as Addresses. At `2bd5a61e8304`, native window at the default size, 16 unused addresses, **Wallet settings → Addresses** showing unless noted. Crashed means the process was gone within 0.3 s of the event with SIGBUS or SIGTRAP: | Case | Crashed | |---|---| | Nothing happens | 0 of 10 | | One incoming payment | 0 of 20 | | Two incoming payments about 10 ms apart | 7 of 10, 7 of 10, 7 of 14 | | Two incoming payments 50 ms / 200 ms apart | 1 of 10 / 0 of 10 | | 20 incoming payments back to back | 9 of 10 | | One block confirming 20 of the wallet's payments / 2 of them | 8 of 10 / 3 of 10 | | 20 `getnewaddress` calls | 10 of 10 | | Addresses opened, then **Activity** showing: 20 payments / two payments | 8 of 10 / 3 of 10 | | Addresses opened and closed with Back, then 20 payments | 0 of 6 | | Addresses never opened, same events | 0 of 60 | | Offscreen platform | 0 of 11 | `eed1f426fcb6` gave the same: 9 of 10 with 20 payments, 6 of 10 with two. The same with **Wallet settings → View coins** in place of Addresses, in launches where Addresses was never opened. Wallet with 20 coins unless noted; about three rows fit at the default window size: | Case | Crashed | |---|---| | Nothing happens | 0 of 10 | | One incoming payment | 0 of 10 | | Two incoming payments about 10 ms apart | 5 of 10, 6 of 10 | | 20 incoming payments back to back | 7 of 10 | | One block confirming 20 of the wallet's payments / 2 of them | 5 of 10 / 3 of 10 | | View coins opened, then **Activity** showing: two payments / block confirming two / one payment | 1 of 10 / 2 of 10 / 0 of 10 | | View coins opened and closed with Back: two payments / 20 payments | 0 of 10 / 0 of 10 | | View coins never opened, Activity showing: two payments / 20 payments | 0 of 10 / 0 of 10 | | Wallet with 2 coins, which both fit: 20 payments | 0 of 10 | | Wallet with 4 / 6 / 8 coins: two payments | 0 of 8 / 3 of 8 / 2 of 8 | `eed1f426fcb6`: 6 of 10 with 20 payments, 0 of 10 with one. With a second regtest node on localhost as the app's only peer, holding the paying wallet, so that nothing was sent to the app's own RPC: | Case, delivered by the peer | Crashed | |---|---| | View coins showing: the peer mines a block confirming two pending payments | 5 of 10 | | View coins showing: two payments submitted to the peer together and relayed | 5 of 10 | | View coins showing: one payment relayed | 0 of 10 | | View coins showing: peer connected, nothing sent | 0 of 5 | | Addresses showing: the peer mines a block confirming two pending payments | 4 of 10 | The two relayed payments reached the wallet 5 to 11 ms apart and the two confirmations 4 to 14 ms apart. In the same rounds as the peer table the two-payment case on Addresses, over RPC, crashed 10 of 11. Between two `bitcoind` nodes with no GUI, two payments submitted to the relaying node up to 2 s apart reached the receiving wallet 5 to 18 ms apart in 11 of 12 tries; submitted 4 s apart they arrived seconds apart in 3 of 3. The address model refreshes on `balanceChanged` as well as on the address-book signal, and every wallet transaction emits it, so each payment or confirmation resets the whole list. The coins model is connected to `transactionChanged`, `addressListChanged` and `balanceChanged` and resets twice per call ([coinslistmodel.cpp#L16-L18](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/coinslistmodel.cpp#L16-L18), [coinslistmodel.cpp#L82-L121](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/models/coinslistmodel.cpp#L82-L121)), so each payment or confirmation resets that list four times. Leaving either page by a tab keeps it on the settings stack ([WalletSettingsStack.qml#L72-L108](https://github.com/bitcoin-core/gui-qml/blob/eed1f426fcb64daa61b004590335a03afe376274/qml/pages/wallet/WalletSettingsStack.qml#L72-L108)), so the list is still there to be reset; Back removes it. So a wallet with a screenful of unused addresses, or with six or more coins, with Addresses or View coins opened and left by a tab rather than with Back, can die when a block confirms two of its pending payments, or when two payments arrive together. On the open question: Qt turns its Cocoa accessibility layer on only when another process queries the window, and the faulting frames are behind that check. With the same window manager running throughout, Qt's own log showed the layer active in 13 of 28 launches, and the crash rate followed it: two payments crashed 7 of 10 and 7 of 14 in periods where it was active, 0 of 3 where it mostly was not. I have still not tested with every accessibility client closed, nor with VoiceOver. #990 at `389e2f1dac5c` does not fix this. Run against its base with launches alternating, it crashed 36 of 40 on Addresses against 8 of 28, and 8 of 20 on View coins against 3 of 20; the base ran below its usual rate, so I can't say it is worse, only that it is not better. A burst becomes one reset per worker round and the coins model listens to the same coalesced signal, but the resets are still full, the coins model still resets twice per refresh, and two a round apart remain. The numbers are in [my comment there](https://github.com/bitcoin-core/gui-qml/pull/990#issuecomment-6864222454). Limits: - I took no stack for these cases. The link to the trace above rests on the same reset, the same lists, the same timing and the same controls. The Addresses cases ended with SIGBUS or SIGTRAP, the View coins cases with SIGBUS only. - Except in the peer table, payments and blocks were sent over RPC to the app's own regtest node. I did not send a payment from the app's Send page. - On View coins only payments and blocks were tried: no label changes, no new addresses, and not the coin picker on the Send page. - The sets are small and timing-dependent. - macOS arm64 / Qt 6.9.0, isolated regtest.
jarolrod commented 2026-11-14 04:45:39 +00:00 (Migrated from github.com)

On qt6 at efc4a2c754eb, after #1052, the Addresses crash no longer happens in my runs. #1052 does not fix it, though: one change in Skeleton.qml makes it much harder to reach.

I bisected #1052 natively, running 2bd5a61e8304 in the same minutes as a control at every step (Addresses showing, 20 payments back to back, window active). ad3a496a86 crashed in 5 of 5 launches. The next commit, 2cca32e868, crashed in 0 of 5, while the control crashed in 5 of 5. That commit changed Skeleton.qml from running: loading to running: root.loading && root.visible && …. Before it, the three loading skeletons in the hidden column of the Activity page animated for the whole session. Removing only root.visible on efc4a2c754eb brings the crash back (4 of 6, published stack; unchanged build 0 of 6). Adding only && root.visible on 2bd5a61e8304 stops it (0 of 6; unchanged build 4 of 6).

While any animation runs, Qt builds the asynchronous rows below the visible area right after each frame, so the next model reset finds a row half built and cancels it. When nothing animates, the row has not been started when the next reset comes. With a row half built, Qt 6.9.0 fails in two ways:

  • The published SIGBUS: while the half-built row is deleted, its details button (Accessible.name, no role) sends an accessibility hide event before componentComplete() set its role, and QAccessibleQuickItem::role calls the QQuickControl virtual accessibleRole() on an object that is by then only a QQuickItem. Explicit roles on that button and AddressLabel removed this crash.
  • A SIGTRAP ("memory corruption of free block") when the row is cancelled during finalization: the ContextMenu attached object of the Basic TextField writes through a stale back-pointer into the object creator's freed memory (qqmlobjectcreator.cpp:863-874). This one is inferred from the code and from the fact that using the Templates TextField removed it. Qt 6.10 removed these back-pointers (qt/qtdeclarative@72b4dff6c0).

On efc4a2c754eb the full resets, the role-less details button and the Basic TextField are unchanged, so any animation running during a burst of notifications can bring the crash back. View coins with one hidden animation running crashed in 1 of 5 launches. I would keep this open until the resets are coalesced or rows are updated in place.

macOS arm64 / Qt 6.9.0, isolated regtest, native window. Steps went through the test bridge and payments came over RPC. The bisect and the on/off experiments used local builds; I am not proposing any of those changes.

On `qt6` at `efc4a2c754eb`, after #1052, the Addresses crash no longer happens in my runs. #1052 does not fix it, though: one change in `Skeleton.qml` makes it much harder to reach. I bisected #1052 natively, running `2bd5a61e8304` in the same minutes as a control at every step (Addresses showing, 20 payments back to back, window active). `ad3a496a86` crashed in 5 of 5 launches. The next commit, `2cca32e868`, crashed in 0 of 5, while the control crashed in 5 of 5. That commit changed `Skeleton.qml` from `running: loading` to `running: root.loading && root.visible && …`. Before it, the three loading skeletons in the hidden column of the Activity page animated for the whole session. Removing only `root.visible` on `efc4a2c754eb` brings the crash back (4 of 6, published stack; unchanged build 0 of 6). Adding only `&& root.visible` on `2bd5a61e8304` stops it (0 of 6; unchanged build 4 of 6). While any animation runs, Qt builds the asynchronous rows below the visible area right after each frame, so the next model reset finds a row half built and cancels it. When nothing animates, the row has not been started when the next reset comes. With a row half built, Qt 6.9.0 fails in two ways: - The published SIGBUS: while the half-built row is deleted, its details button (`Accessible.name`, no role) sends an accessibility hide event before `componentComplete()` set its role, and `QAccessibleQuickItem::role` calls the `QQuickControl` virtual `accessibleRole()` on an object that is by then only a `QQuickItem`. Explicit roles on that button and `AddressLabel` removed this crash. - A SIGTRAP ("memory corruption of free block") when the row is cancelled during finalization: the `ContextMenu` attached object of the Basic `TextField` writes through a stale back-pointer into the object creator's freed memory ([qqmlobjectcreator.cpp:863-874](https://github.com/qt/qtdeclarative/blob/v6.9.0/src/qml/qml/qqmlobjectcreator.cpp#L863-L874)). This one is inferred from the code and from the fact that using the Templates `TextField` removed it. Qt 6.10 removed these back-pointers (qt/qtdeclarative@72b4dff6c0ba). On `efc4a2c754eb` the full resets, the role-less details button and the Basic `TextField` are unchanged, so any animation running during a burst of notifications can bring the crash back. View coins with one hidden animation running crashed in 1 of 5 launches. I would keep this open until the resets are coalesced or rows are updated in place. macOS arm64 / Qt 6.9.0, isolated regtest, native window. Steps went through the test bridge and payments came over RPC. The bisect and the on/off experiments used local builds; I am not proposing any of those changes.
Sign in to join this conversation.
No description provided.