The application would either quit or std::exit on failure and not even try a shutdown.
Note that bitcoind does a Interrupt and Shutdown in case the initialization fails or an exception is caught. So just do the same for the gui.
The application would either quit or std::exit on failure and not even try a shutdown.
Note that bitcoind does a Interrupt and Shutdown in case the initialization fails or an exception is caught. So just do the same for the gui.
Concept ACK
523 | @@ -513,10 +524,6 @@ void BitcoinApplication::initializeResult(bool success) 524 | QTimer::singleShot(100, paymentServer, SLOT(uiReady())); 525 | #endif 526 | pollShutdownTimer->start(200); 527 | - } else { 528 | - Q_EMIT splashFinished(window); // Make sure splash screen doesn't stick around during shutdown
Add try/catch here instead? Otherwise should fix indentation above.
250 | @@ -251,6 +251,10 @@ BitcoinCore::BitcoinCore(interfaces::Node& node) : 251 | void BitcoinCore::handleRunawayException(const std::exception *e) 252 | { 253 | PrintExceptionContinue(e, "Runaway exception"); 254 | + try { 255 | + m_node.appShutdown(); 256 | + } catch (...) { 257 | + }
Could log something? Same below.
Any suggestions? Note that I'd rather not write to the debug.log, since that might be the cause of the exception.
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!
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.
Concept ACK
Added a commit to print the exception (per common request)
470 | @@ -465,8 +471,17 @@ void BitcoinApplication::initializeResult(bool success) 471 | qDebug() << __func__ << ": Initialization result: " << success; 472 | // Set exit result. 473 | returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; 474 | - if(success) 475 | - { 476 | + if (!success) { 477 | + try { 478 | + m_node.appShutdown();
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():
which should trigger requestedShutdown():
which should trigger BitcoinCore::shutdown:
which already calls appShutdown():
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.
250 | @@ -251,6 +251,12 @@ BitcoinCore::BitcoinCore(interfaces::Node& node) : 251 | void BitcoinCore::handleRunawayException(const std::exception *e) 252 | { 253 | PrintExceptionContinue(e, "Runaway exception"); 254 | + try { 255 | + m_node.appShutdown(); 256 | + } catch (const std::exception& e) { 257 | + PrintExceptionContinue(&e, __func__); 258 | + } catch (...) { 259 | + }
Could call PrintExceptionContinue(nullptr) in these empty catches. boost::current_exception_diagnostic_information() could also be used to add more detail.
250 | @@ -251,6 +251,12 @@ BitcoinCore::BitcoinCore(interfaces::Node& node) : 251 | void BitcoinCore::handleRunawayException(const std::exception *e) 252 | { 253 | PrintExceptionContinue(e, "Runaway exception"); 254 | + try { 255 | + m_node.appShutdown();
This doesn't seem like the right place to be calling appShutdown. The emit below is supposed to trigger BitcoinApplication::handleRunawayException:
which is supposed to show an error dialog and then exit:
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.
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.
I marked this up for grabs for someone to pick up and address the useful feedback by @ryanofsky
250 | @@ -251,6 +251,12 @@ BitcoinCore::BitcoinCore(interfaces::Node& node) : 251 | void BitcoinCore::handleRunawayException(const std::exception *e) 252 | { 253 | PrintExceptionContinue(e, "Runaway exception"); 254 | + try { 255 | + m_node.appShutdown(); 256 | + } catch (const std::exception& e) {
e here shadows the function parameter in BitcoinCore::handleRunawayException(const std::exception *e).
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
Closing, leaving Up for grabs.