Skip to content

Merge bitcoin-core/gui#765: Fix wallet list hover crash on shutdown#569

Open
DashCoreAutoGuix wants to merge 1 commit intobackport-0.23-batch-492from
backport-0.23-batch-492-pr-765
Open

Merge bitcoin-core/gui#765: Fix wallet list hover crash on shutdown#569
DashCoreAutoGuix wants to merge 1 commit intobackport-0.23-batch-492from
backport-0.23-batch-492-pr-765

Conversation

@DashCoreAutoGuix
Copy link
Owner

@DashCoreAutoGuix DashCoreAutoGuix commented Jul 28, 2025

$(cat <<'EOF'
Backports bitcoin/bitcoin-core/gui#765

Original commit: 9270453

Note: This PR was later reverted in bitcoin-core/gui#770

This PR fixes a crash that occurs when the user hovers over the wallets list during shutdown. The fix adds proper lifetime management by passing m_wallet_controller as context to lambdas that access wallet-related functionality, and clears the application menu bar during shutdown to prevent access to invalidated objects.

Backported from Bitcoin Core v0.26
EOF
)

Summary by CodeRabbit

  • Refactor

    • Improved internal handling of wallet-related menu actions for enhanced stability.
  • Bug Fixes

    • The main menu bar is now properly disabled during shutdown, providing clearer feedback when the application is closing.

@coderabbitai
Copy link

coderabbitai bot commented Jul 28, 2025

Warning

Rate limit exceeded

@DashCoreAutoGuix has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ceed1d37127e356eaacf24a98058d11b669df061 and 1dc0ab2.

📒 Files selected for processing (1)
  • src/qt/bitcoingui.cpp (6 hunks)

Walkthrough

The changes update several lambda signal-slot connections in BitcoinGUI::createActions() to explicitly capture m_wallet_controller as the context object. Additionally, in BitcoinGUI::setClientModel(), the main menu bar is now cleared when the client model is set to null, disabling it during shutdown. No logic inside the lambdas or wallet operations was altered.

Changes

Cohort / File(s) Change Summary
Lambda Context and Menu Bar Handling
src/qt/bitcoingui.cpp
Lambdas in wallet-related signal-slot connections now capture m_wallet_controller explicitly as context. The main menu bar is cleared in shutdown by calling appMenuBar->clear() when the client model is set to null. No internal logic changes to lambdas or wallet operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backport-0.23-batch-492-pr-765

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@kwvg kwvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request needs to be rebased on develop to resolve issues due to a logical conflict that has been resolved. This applies to both target and head branches.

@DashCoreAutoGuix
Copy link
Owner Author

❌ Backport Verification - Issues Detected

Original Bitcoin commit: 92704535f6
Reviewed commit hash: ceed1d3712-verify-1753731005

Issues found:

  • CI failures: 5 build failures across all platforms - caused by PR branch being behind develop, missing logical conflict resolution

Fix identified but cannot be pushed automatically:
The PR needs to be rebased onto the latest develop branch to resolve build failures. The PR is currently based on an older commit and is missing the logical conflict fix from dashpay#6783.

Manual steps to fix:

git rebase upstream/develop
git push origin HEAD --force-with-lease
❌ Range-diff
1:  7066e8996d ! 1:  ceed1d3712 gui: provide wallet controller context to wallet actions
    @@
      ## Metadata ##
    -Author: furszy <matiasfurszyfer@protonmail.com>
    +Author: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
     
      ## Commit message ##
    -    gui: provide wallet controller context to wallet actions
    +    Merge bitcoin-core/gui#765: Fix wallet list hover crash on shutdown
     
    -    Addressing potential crashes during shutdown. The most
    -    noticeable one can be triggered by hovering over the
    -    wallet list as the app shuts down.
    +    8b6470a90652fcffc45b8d7998af7c8ad6251332 gui: disable top bar menu actions during shutdown (furszy)
    +    7066e8996d0ac090535cc97cdcb54a219986460f gui: provide wallet controller context to wallet actions (furszy)
    +
    +    Pull request description:
    +
    +      Small follow-up to #751.
    +
    +      Fixes another crash cause during shutdown. Which occurs when the user hovers over the wallets list.
    +
    +      Future Note:
    +      This surely happen in other places as well, we should re-work the way we connect signals. Register
    +      lambas without any precaution can leave dangling pointers.
    +
    +    ACKs for top commit:
    +      hebasto:
    +        ACK 8b6470a90652fcffc45b8d7998af7c8ad6251332, I've tested each commit separately on macOS Sonoma 14.0 (Apple M1).
    +
    +    Tree-SHA512: 6fbd1bcd6717a8c1633beb9371463ed22422f929cccf9b791ee292c5364134c501e099329cf77a06b74a84c64c1c3d22539199ec49ccd74b3950036316c0dab3
     
      ## src/qt/bitcoingui.cpp ##
     @@ src/qt/bitcoingui.cpp: void BitcoinGUI::createActions()
    @@ src/qt/bitcoingui.cpp: void BitcoinGUI::createActions()
     +        connect(m_close_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
                  m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
              });
    -         connect(m_create_wallet_action, &QAction::triggered, this, &BitcoinGUI::createWallet);
    +-        connect(m_create_wallet_action, &QAction::triggered, [this] {
    ++        connect(m_create_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
    +             auto activity = new CreateWalletActivity(m_wallet_controller, this);
    +             connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
    +             connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
    +             activity->create();
    +         });
     -        connect(m_close_all_wallets_action, &QAction::triggered, [this] {
     +        connect(m_close_all_wallets_action, &QAction::triggered, m_wallet_controller, [this] {
                  m_wallet_controller->closeAllWallets(this);
              });
    --        connect(m_migrate_wallet_action, &QAction::triggered, [this] {
    -+        connect(m_migrate_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
    -             auto activity = new MigrateWalletActivity(m_wallet_controller, this);
    -             connect(activity, &MigrateWalletActivity::migrated, this, &BitcoinGUI::setCurrentWallet);
    -             activity->migrate(walletFrame->currentWalletModel());
    +-
    +         connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);
    +     }
    + #endif // ENABLE_WALLET
    +@@ src/qt/bitcoingui.cpp: void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
    +             connect(optionsModel, &OptionsModel::coinJoinEnabledChanged, this, &BitcoinGUI::updateCoinJoinVisibility);
    +         }
    +     } else {
    +-        if(trayIconMenu)
    ++        // Shutdown requested, disable menus
    ++        if (trayIconMenu)
    +         {
    +             // Disable context menu on tray icon
    +             trayIconMenu->clear();
    +@@ src/qt/bitcoingui.cpp: void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
    +             dockIconMenu->clear();
    +         }
    + #endif
    ++        // Disable top bar menu actions
    ++        appMenuBar->clear();
    +     }
    + 
    +     updateCoinJoinVisibility();
2:  8b6470a906 < -:  ---------- gui: disable top bar menu actions during shutdown

To reproduce, run:

git --no-pager range-diff --creation-factor=99 92704535f6^..92704535f6 ceed1d3712^..ceed1d3712

Please rebase the PR onto develop and the CI should pass.

@DashCoreAutoGuix DashCoreAutoGuix added needs-fixes Requires manual fixes to address verification issues and removed needs-fixes Requires manual fixes to address verification issues labels Jul 28, 2025
@DashCoreAutoGuix
Copy link
Owner Author

❌ Backport Verification - Issues Detected

Original Bitcoin commit: 92704535f6
Reviewed commit hash: ceed1d3712-verify-1753733624

Issues found:

  • Scope creep: Extra file src/test/llmq_commitment_tests.cpp modified that wasn't in Bitcoin commit
  • CI failures: 5 build failures across all platforms due to API method error (get_int vs getInt<int>)

Root cause: Bitcoin commit only modified src/qt/bitcoingui.cpp for GUI crash fix, but Dash PR also included unrelated LLMQ test changes that use incorrect API.

Fix identified but couldn't push due to authentication:

diff --git a/src/test/llmq_commitment_tests.cpp b/src/test/llmq_commitment_tests.cpp
index cfc193f427..0042368585 100644
--- a/src/test/llmq_commitment_tests.cpp
+++ b/src/test/llmq_commitment_tests.cpp
@@ -142,8 +142,8 @@ BOOST_AUTO_TEST_CASE(commitment_json_test)
     BOOST_CHECK(json.exists("signersCount"));
     BOOST_CHECK(json.exists("validMembersCount"));
 
-    BOOST_CHECK_EQUAL(json["signersCount"].get_int(), commitment.CountSigners());
-    BOOST_CHECK_EQUAL(json["validMembersCount"].get_int(), commitment.CountValidMembers());
+    BOOST_CHECK_EQUAL(json["signersCount"].getInt<int>(), commitment.CountSigners());
+    BOOST_CHECK_EQUAL(json["validMembersCount"].getInt<int>(), commitment.CountValidMembers());
 }
 
 BOOST_AUTO_TEST_CASE(commitment_bitvector_json_test)

Manual fix instructions:

  1. Revert src/test/llmq_commitment_tests.cpp to use getInt<int>() instead of get_int()
  2. This will resolve all CI build failures

Please apply this fix and re-run verification.

@DashCoreAutoGuix DashCoreAutoGuix added needs-fixes Requires manual fixes to address verification issues and removed needs-fixes Requires manual fixes to address verification issues labels Jul 28, 2025
@DashCoreAutoGuix
Copy link
Owner Author

❌ Backport Verification - Issues Detected

Original Bitcoin commit: 92704535f6
Reviewed commit hash: ceed1d3712-verify-1753735402

Issues found:

  • CI build failures: UniValue method name mismatch - code uses get_int() but should use getInt()
  • Error occurs in test/llmq_commitment_tests.cpp lines 145-146
  • Affects all build platforms (linux64, win64, mac, arm-linux)

Fix Applied (unable to push due to auth):

diff --git a/src/test/llmq_commitment_tests.cpp b/src/test/llmq_commitment_tests.cpp
index cfc193f427..bdff2f9b16 100644
--- a/src/test/llmq_commitment_tests.cpp
+++ b/src/test/llmq_commitment_tests.cpp
@@ -142,8 +142,8 @@ BOOST_AUTO_TEST_CASE(commitment_json_test)
     BOOST_CHECK(json.exists("signersCount"));
     BOOST_CHECK(json.exists("validMembersCount"));
 
-    BOOST_CHECK_EQUAL(json["signersCount"].get_int(), commitment.CountSigners());
-    BOOST_CHECK_EQUAL(json["validMembersCount"].get_int(), commitment.CountValidMembers());
+    BOOST_CHECK_EQUAL(json["signersCount"].getInt(), commitment.CountSigners());
+    BOOST_CHECK_EQUAL(json["validMembersCount"].getInt(), commitment.CountValidMembers());
 }
 
 BOOST_AUTO_TEST_CASE(commitment_bitvector_json_test)

Please apply this fix manually and re-run CI. The backport is otherwise valid with good size ratio (105.9%) and no other issues.

@DashCoreAutoGuix DashCoreAutoGuix added the needs-fixes Requires manual fixes to address verification issues label Jul 28, 2025
8b6470a gui: disable top bar menu actions during shutdown (furszy)
7066e89 gui: provide wallet controller context to wallet actions (furszy)

Pull request description:

  Small follow-up to #751.

  Fixes another crash cause during shutdown. Which occurs when the user hovers over the wallets list.

  Future Note:
  This surely happen in other places as well, we should re-work the way we connect signals. Register
  lambas without any precaution can leave dangling pointers.

ACKs for top commit:
  hebasto:
    ACK 8b6470a, I've tested each commit separately on macOS Sonoma 14.0 (Apple M1).

Tree-SHA512: 6fbd1bcd6717a8c1633beb9371463ed22422f929cccf9b791ee292c5364134c501e099329cf77a06b74a84c64c1c3d22539199ec49ccd74b3950036316c0dab3
@PastaPastaPasta PastaPastaPasta force-pushed the backport-0.23-batch-492-pr-765 branch from ceed1d3 to 1dc0ab2 Compare July 28, 2025 21:03
@DashCoreAutoGuix DashCoreAutoGuix removed the needs-fixes Requires manual fixes to address verification issues label Jul 28, 2025
@DashCoreAutoGuix
Copy link
Owner Author

✅ Backport Verification Successful

No issues found! This backport is complete and faithful to the original Bitcoin change.

Original Bitcoin commit: 92704535f6
Reviewed commit hash: 1dc0ab2ff5-verify-1753737202

✅ Range-diff
1:  7066e8996d \! 1:  1dc0ab2ff5 gui: provide wallet controller context to wallet actions
    @@
      ## Metadata ##
    -Author: furszy <matiasfurszyfer@protonmail.com>
    +Author: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
     
      ## Commit message ##
    -    gui: provide wallet controller context to wallet actions
    +    Merge bitcoin-core/gui#765: Fix wallet list hover crash on shutdown
     
    -    Addressing potential crashes during shutdown. The most
    -    noticeable one can be triggered by hovering over the
    -    wallet list as the app shuts down.
    +    8b6470a90652fcffc45b8d7998af7c8ad6251332 gui: disable top bar menu actions during shutdown (furszy)
    +    7066e8996d0ac090535cc97cdcb54a219986460f gui: provide wallet controller context to wallet actions (furszy)
    +
    +    Pull request description:
    +
    +      Small follow-up to #751.
    +
    +      Fixes another crash cause during shutdown. Which occurs when the user hovers over the wallets list.
    +
    +      Future Note:
    +      This surely happen in other places as well, we should re-work the way we connect signals. Register
    +      lambas without any precaution can leave dangling pointers.
    +
    +    ACKs for top commit:
    +      hebasto:
    +        ACK 8b6470a90652fcffc45b8d7998af7c8ad6251332, I've tested each commit separately on macOS Sonoma 14.0 (Apple M1).
    +
    +    Tree-SHA512: 6fbd1bcd6717a8c1633beb9371463ed22422f929cccf9b791ee292c5364134c501e099329cf77a06b74a84c64c1c3d22539199ec49ccd74b3950036316c0dab3
     
      ## src/qt/bitcoingui.cpp ##
     @@ src/qt/bitcoingui.cpp: void BitcoinGUI::createActions()
    @@ src/qt/bitcoingui.cpp: void BitcoinGUI::createActions()
     +        connect(m_close_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
              m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
          });
    -         connect(m_create_wallet_action, &QAction::triggered, this, &BitcoinGUI::createWallet);
    +-        connect(m_create_wallet_action, &QAction::triggered, [this] {
    ++        connect(m_create_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
    +             auto activity = new CreateWalletActivity(m_wallet_controller, this);
    +             connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
    +             connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
    +             activity->create();
    +         });
     -        connect(m_close_all_wallets_action, &QAction::triggered, [this] {
     +        connect(m_close_all_wallets_action, &QAction::triggered, m_wallet_controller, [this] {
              m_wallet_controller->closeAllWallets(this);
          });
    +-
    +         connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);
    +     }
    + #endif // ENABLE_WALLET
    +@@ src/qt/bitcoingui.cpp: void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
    +             connect(optionsModel, &OptionsModel::coinJoinEnabledChanged, this, &BitcoinGUI::updateCoinJoinVisibility);
    +         }
    +     } else {
    +-        if(trayIconMenu)
    ++        // Shutdown requested, disable menus
    ++        if (trayIconMenu)
    +         {
    +             // Disable context menu on tray icon
    +             trayIconMenu->clear();
    +@@ src/qt/bitcoingui.cpp: void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
    +             dockIconMenu->clear();
    +         }
    + #endif
    ++        // Disable top bar menu actions
    ++        appMenuBar->clear();
    +     }
    + 
    +     updateCoinJoinVisibility();
2:  8b6470a906 < -:  ---------- gui: disable top bar menu actions during shutdown

To reproduce, run:

git --no-pager range-diff --no-dual-color --creation-factor=99 7066e8996d0ac090535cc97cdcb54a219986460f^..8b6470a90652fcffc45b8d7998af7c8ad6251332 3b3169d47010b03f8f068152a93ae60433bf566b..origin/pr/569

This PR is ready for merge. ✅

@DashCoreAutoGuix DashCoreAutoGuix added the verified Backport verification passed - ready for merge label Jul 28, 2025
@PastaPastaPasta PastaPastaPasta removed the verified Backport verification passed - ready for merge label Dec 2, 2025
@DashCoreAutoGuix
Copy link
Owner Author

✅ Verification Complete

Bitcoin Source: bitcoin-core/gui#765 (commit 92704535f6)

Summary

This PR correctly backports a fix for wallet list hover crash on shutdown. The fix adds a context parameter (m_wallet_controller) to lambda signal connections to prevent crashes when hovering over wallet items during shutdown.

Validation Results

  • CI Status: All 51 checks passed
  • Size Ratio: 105.9% (within 80-150% acceptable range)
  • File Count: 1 file (matches Bitcoin)
  • Faithful Backport: All changes correctly adapted

Dash-Specific Adaptations

  1. Expected difference: Bitcoin modified 7 lambda connections; Dash modified 6. This is correct because Dash doesn't have m_migrate_wallet_action (wallet migration feature).
  2. Correct adaptation: m_create_wallet_action connection properly adapted (Dash uses inline lambda, Bitcoin uses function pointer).
  3. Consistent changes: Both added appMenuBar->clear() on shutdown and fixed whitespace.

Reviewer Note

The review comment from @kwvg requesting rebase appears to be addressed - commit 3b3169d resolved the logical conflict before this PR was merged into the batch.

Status: APPROVED ✅

@DashCoreAutoGuix DashCoreAutoGuix added the verified Backport verification passed - ready for merge label Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

verified Backport verification passed - ready for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants