fix: crash when theme is changed if mnemonic dialog has been shown#7126
fix: crash when theme is changed if mnemonic dialog has been shown#7126PastaPastaPasta merged 2 commits intodashpay:developfrom
Conversation
This call disconnect(cancel, nullptr, nullptr, nullptr) for cancel makes an internal slots disconnected and it could cause objects to get invalid internal state at some point if theme is changed.
…rification dialog It is supposed to go backwards only if it's validation screen, otherwise it should close dialog
✅ No Merge Conflicts DetectedThis PR currently has no conflicts with other open PRs. |
WalkthroughThe changes refactor the mnemonic verification dialog's button handling mechanism. The "Back" button UI element is removed from the step 2 page in the form definition. In the C++ implementation, back-navigation logic is centralized into a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
…nd reducing exposure of sensitive data b847bae fix: restore eager clearing of parsed words and improve secure memory handling (UdjinM6) b8b0c1c fmt: fix formatting for mnemonicverificatinodialog (Konstantin Akimov) 1edec05 fix: add mnemonicverificationdialog to non-backported list (Konstantin Akimov) f5d8b74 fix: avoid extra allocation of secured data in temporary std::string for mnemonic (Konstantin Akimov) c7e3b46 refactor: SecureString already does zeroeing, remove duplicated code (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Firstly, current implementation of mnemonic dialog has zeroing of SecureString's objects with std::fill which is useless, and most likely even removed by optimizing compiler. For reference, `SecureString`'s implementation of it, see [src/support/cleanse.cpp](https://github.com/dashpay/dash/blob/develop/src/support/cleanse.cpp) for details: void deallocate(T* p, std::size_t n) { if (p != nullptr) { memory_cleanse(p, sizeof(T) * n); // <- safe memory cleaning } LockedPoolManager::Instance().free(p); } Secondly, current implementation causes creating extra temporary object with sensitive data: QString mnemonicStr = QString::fromStdString(std::string(m_mnemonic.begin(), m_mnemonic.end())); This std::string object maybe omitted, see PR ## What was done? This PR tidy-up a bit mnemonic dialog by fixing these issues and some minor improvements for formatting. Though, using `memory_cleanse` should be considered to use for QStrings. This PR conflicts to #7126 because the same function is changed; I will prefer #7126 to be merged first because 7126 is meant to be backported. ## How Has This Been Tested? Tested as an extra changes to #7126 locally in the same branch, splitted to 2 PR after that. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only) ACKs for top commit: UdjinM6: utACK b847bae Tree-SHA512: c843a39b49f76c6647d004e1044fd4d24ecc4a82ccc311c50d4a88989bfcd62ac1cec09079c3ac40e5efd9e3790115625e65eedb10fc03bfd6475272cb0df72e
Issue being fixed or feature implemented
First found by thepez while testing #7040
It happens every time when create new wallet after dialog to validate mnemonic has been shown.
Steps to reproduce:
Current call
disconnect(cancel, nullptr, nullptr, nullptr)is too violent for qt objects because it disconnects not only user-added slots, but internal qt slots too; it makes the object Cancel Button to be in an invalid state.What was done?
Easiest fix is specify some arguments for disconnect, for example, simple
disconnect(cancel, &QDialogButtonBox::rejected, this, nullptr);fixes crash but it breaks functionality of Cancel button.For the final solution look to the commits in PR
How Has This Been Tested?
Tested numerous user cases (list is not full):
Also I tried to do the exactly same things, but instead mouse's click use Escape or Ctrl+W or close window by mouse.
I am not sure that I provided 100% coverage by manual testing, but at this point it looks solid for me. Any extra testing is welcome, please help with it!
Breaking Changes
N/A
Checklist: