-
Notifications
You must be signed in to change notification settings - Fork 38.7k
gui: Try shutdown also on failure #13880
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
Conversation
|
Might fix #12337 |
|
Concept ACK |
promag
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.
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.
Add try/catch here instead? Otherwise should fix indentation above.
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.
Could log something? Same below.
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.
Any suggestions? Note that I'd rather not write to the debug.log, since that might be the cause of the exception.
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 tend to agree that blanket-ignoring exceptions is very bad. Even printing to stderr would be better to at least have a potential chance of someone diagnosing of seeing the error!
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 gui is not always started from the command line, so that would be missed often as well. But I guess I could add it.
|
Concept ACK |
|
Added a commit to print the exception (per common request) |
ryanofsky
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.
This PR is confusing and I think it is trying to do too many things. It would be easier to understand smaller PRs targeted at specific, reproducible problems.
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.
I don't think it is right to call appShutdown() here because it should be covered by return quit(); below. quit should cause the first application loop to quit, which should trigger requestShutdown():
Lines 718 to 720 in 59ecacf
| app.exec(); | |
| app.requestShutdown(); | |
| app.exec(); |
which should trigger requestedShutdown():
Lines 404 to 431 in 59ecacf
| void BitcoinApplication::requestShutdown() | |
| { | |
| // Show a simple window indicating shutdown status | |
| // Do this first as some of the steps may take some time below, | |
| // for example the RPC console may still be executing a command. | |
| shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window)); | |
| qDebug() << __func__ << ": Requesting shutdown"; | |
| startThread(); | |
| window->hide(); | |
| window->setClientModel(0); | |
| pollShutdownTimer->stop(); | |
| #ifdef ENABLE_WALLET | |
| window->removeAllWallets(); | |
| for (WalletModel *walletModel : m_wallet_models) { | |
| delete walletModel; | |
| } | |
| m_wallet_models.clear(); | |
| #endif | |
| delete clientModel; | |
| clientModel = 0; | |
| m_node.startShutdown(); | |
| // Request shutdown from core thread | |
| Q_EMIT requestedShutdown(); | |
| } |
which should trigger BitcoinCore::shutdown:
Line 379 in 59ecacf
| connect(this, &BitcoinApplication::requestedShutdown, executor, &BitcoinCore::shutdown); |
which already calls appShutdown():
Lines 268 to 281 in 59ecacf
| void BitcoinCore::shutdown() | |
| { | |
| try | |
| { | |
| qDebug() << __func__ << ": Running Shutdown in thread"; | |
| m_node.appShutdown(); | |
| qDebug() << __func__ << ": Shutdown finished"; | |
| Q_EMIT shutdownResult(); | |
| } catch (const std::exception& e) { | |
| handleRunawayException(&e); | |
| } catch (...) { | |
| handleRunawayException(nullptr); | |
| } | |
| } |
The shutdown process is definitely overcomplicated and should be simplified. I think a good direction would be to stop calling QApplication::quit during shutdown and instead just call it after. So Qt shutdown would just immediately follow bitcoin shutdown instead of being mingled with it.
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.
Could call PrintExceptionContinue(nullptr) in these empty catches. boost::current_exception_diagnostic_information() could also be used to add more detail.
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.
This doesn't seem like the right place to be calling appShutdown. The emit below is supposed to trigger BitcoinApplication::handleRunawayException:
Line 377 in 59ecacf
| connect(executor, &BitcoinCore::runawayException, this, &BitcoinApplication::handleRunawayException); |
which is supposed to show an error dialog and then exit:
Lines 523 to 527 in 59ecacf
| void BitcoinApplication::handleRunawayException(const QString &message) | |
| { | |
| QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + message); | |
| ::exit(EXIT_FAILURE); | |
| } |
If you shut down in BitcoinCore::handleRunawayException, it seems like this is going to delay the dialog from showing up, and maybe even prevent it from being seen by the user. But if this is really an improvement, it would be good to have a comment explaining what the shutdown sequence is.
|
I marked this up for grabs for someone to pick up and address the useful feedback by @ryanofsky |
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.
e here shadows the function parameter in BitcoinCore::handleRunawayException(const std::exception *e).
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
fa9bda1 to
5263d45
Compare
5263d45 to
fd65a6d
Compare
|
Closing, leaving |
The application would either
quitorstd::exiton failure and not even try a shutdown.Note that bitcoind does a
InterruptandShutdownin case the initialization fails or an exception is caught. So just do the same for the gui.