-
Notifications
You must be signed in to change notification settings - Fork 38.7k
gui: Fix shutdown order #15280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gui: Fix shutdown order #15280
Conversation
Sjors
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, but paging @Empact, @laanwj, @LeandroRocha84 #13217 and @MarcoFalke #13880 as QT shutdown connoisseurs.
src/qt/bitcoin.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this move, either in a comment or in the commit message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The m_wallet_controller must be deleted after window (because it's used there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I meant in a source code comment though :-) The shutdown logic keeps causing headaches, so there's no such thing as too much documentation I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add if I need to update this branch for other reasons, otherwise I'll improve the shutdown even further with more comments. From testing this is enough to get #15153 working without problems.
src/qt/bitcoingui.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: might as well merge this with the next commit, which explains why this exposure is needed..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to have move only separate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to combine exposing a new interface with adding uses for it - I think of it as an expression of the outside-in development principle, the use comes before the changes it motivates/justifies.
src/qt/bitcoin.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you moved startShutdown(); up? Is it because setClientModel could be blocking and so you can to get this over with first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling setClientModel(nullptr) hits:
Lines 688 to 692 in 7275365
| if (!model) { | |
| // Client model is being set to 0, this means shutdown() is about to be called. | |
| thread.quit(); | |
| thread.wait(); | |
| } |
and if there is a rescan in progress it blocks until the rescan completes. Calling m_node.startShutdown(); causes the rescan to interrupt.
|
utACK 870e35c30c0286e729a55fc343ab9b1945619699 |
|
tACK 870e35c30c0286e729a55fc343ab9b1945619699 (Linux) modulo #15280 (comment) and #15280 (comment). |
|
This could benefit from adding "why" to each commit message, which currently only describe what is done. Will be easier to evaluate now and interpret in the future with that info. |
df785ea to
0b53bf9
Compare
|
Improved each commit message (hope it is now more clear). A good test case to check with and without this PR is:
|
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
utACK 0b53bf9 Thanks for expanding those commit messages. Should we also guard in |
|
@Empact different PR IMO. I had a commit to guard it with |
The wallet controller instanced must be deleted after the window instance since it is used there.
Move only change that makes unsubscribeFromCoreSignals public. It must be called if the event loop is not running otherwise core signals handlers can deadlock.
This change forwards the shutdown request on the GUI (close the application for instace) to the node as soon as possible. This way the GUI doesn't have to wait for long operations to complete (rescan the wallet for instance), instead those operations detect the shutdown request and abort/interrupt.
When a wallet is created it is registered in the validation interface (in CWallet::CreateWalletFromFile) but it is not immediately added to the wallets list. If a shutdown is requested before AddWallet (case more evident when -rescan is set) then m_internals can be released (in Shutdown -> UnregisterBackgroundSignalScheduler) before the wallet and then ReleaseWallet would call UnregisterValidationInterface with m_internals already released.
0b53bf9 to
0dd6a8c
Compare
|
utACK 0dd6a8c |
0dd6a8c Check m_internals in UnregisterValidationInterface (João Barbosa) fd6d499 gui: Fix m_node.startShutdown() order (João Barbosa) 07b9aad gui: Expose BitcoinGUI::unsubscribeFromCoreSignals (João Barbosa) 60e190c gui: Fix WalletController deletion (João Barbosa) Pull request description: This PR consists in small fixes in order to have a clean shutdown from the GUI. Tree-SHA512: a9c641f202bc810698c4a39d5c5a1f54e54bdab098c412d65418879e00764a9db9f38383813914d591e24e097e49f177942b2ae6c57bba05dcc095e8a1d0b8f4
Summary: * gui: Fix WalletController deletion The wallet controller instanced must be deleted after the window instance since it is used there. * gui: Expose BitcoinGUI::unsubscribeFromCoreSignals Move only change that makes unsubscribeFromCoreSignals public. It must be called if the event loop is not running otherwise core signals handlers can deadlock. * gui: Fix m_node.startShutdown() order This change forwards the shutdown request on the GUI (close the application for instace) to the node as soon as possible. This way the GUI doesn't have to wait for long operations to complete (rescan the wallet for instance), instead those operations detect the shutdown request and abort/interrupt. * Check m_internals in UnregisterValidationInterface When a wallet is created it is registered in the validation interface (in CWallet::CreateWalletFromFile) but it is not immediately added to the wallets list. If a shutdown is requested before AddWallet (case more evident when -rescan is set) then m_internals can be released (in Shutdown -> UnregisterBackgroundSignalScheduler) before the wallet and then ReleaseWallet would call UnregisterValidationInterface with m_internals already released. This is a backport of Core [[bitcoin/bitcoin#15280 | PR15280]] Test Plan: ninja all check-all Run bitcoin-qt on win64 and verify it shuts down properly. Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D6344
Summary: * gui: Fix WalletController deletion The wallet controller instanced must be deleted after the window instance since it is used there. * gui: Expose BitcoinGUI::unsubscribeFromCoreSignals Move only change that makes unsubscribeFromCoreSignals public. It must be called if the event loop is not running otherwise core signals handlers can deadlock. * gui: Fix m_node.startShutdown() order This change forwards the shutdown request on the GUI (close the application for instace) to the node as soon as possible. This way the GUI doesn't have to wait for long operations to complete (rescan the wallet for instance), instead those operations detect the shutdown request and abort/interrupt. * Check m_internals in UnregisterValidationInterface When a wallet is created it is registered in the validation interface (in CWallet::CreateWalletFromFile) but it is not immediately added to the wallets list. If a shutdown is requested before AddWallet (case more evident when -rescan is set) then m_internals can be released (in Shutdown -> UnregisterBackgroundSignalScheduler) before the wallet and then ReleaseWallet would call UnregisterValidationInterface with m_internals already released. This is a backport of Core [[bitcoin/bitcoin#15280 | PR15280]] Test Plan: ninja all check-all Run bitcoin-qt on win64 and verify it shuts down properly. Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D6344
…ionInterface When a wallet is created it is registered in the validation interface (in CWallet::CreateWalletFromFile) but it is not immediately added to the wallets list. If a shutdown is requested before AddWallet (case more evident when -rescan is set) then m_internals can be released (in Shutdown -> UnregisterBackgroundSignalScheduler) before the wallet and then ReleaseWallet would call UnregisterValidationInterface with m_internals already released.
merge bitcoin#15118, bitcoin#14172, bitcoin#15623, bitcoin#14121, partial bitcoin#13743, partial bitcoin#15280: block filters
0dd6a8c Check m_internals in UnregisterValidationInterface (João Barbosa) fd6d499 gui: Fix m_node.startShutdown() order (João Barbosa) 07b9aad gui: Expose BitcoinGUI::unsubscribeFromCoreSignals (João Barbosa) 60e190c gui: Fix WalletController deletion (João Barbosa) Pull request description: This PR consists in small fixes in order to have a clean shutdown from the GUI. Tree-SHA512: a9c641f202bc810698c4a39d5c5a1f54e54bdab098c412d65418879e00764a9db9f38383813914d591e24e097e49f177942b2ae6c57bba05dcc095e8a1d0b8f4
This PR consists in small fixes in order to have a clean shutdown from the GUI.