Skip to content

Conversation

LeandroRocha84
Copy link

@LeandroRocha84 LeandroRocha84 commented Jul 16, 2018

This pull request contains a fix for the issue #13217, where bitcoin-qt becomes unresponsive during shutdown after a long running call (like gettxoutsetinfo) in the QT console.
The problem occurs because, during shutdown, waiting for the RPCExecutor thread to finish happens in the main thread.

@LeandroRocha84
Copy link
Author

There's also the possibility of emitting the shutdown signal from RPCExecutor destructor so we don't need a wrapper - that simplify the solution. I created the PR with the wrapper solution because it might be considered unsafe to emit signals from a destructor in a multi-threaded application. Would appreciate any input on this and I'll update the PR accordingly.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Indeed looks like unnecessary complexity. IIUC the main even loop blocks when joining the executor thread, so consider a different approach instead?

QEventLoop loop;
connect(&thread, SIGNAL(finished()), &loop, SLOT(quit()));
if (!thread.isFinished()) loop.exec();

@LeandroRocha84 LeandroRocha84 force-pushed the qt-shutdown-13217 branch 3 times, most recently from 7ebd837 to 3844ba3 Compare July 17, 2018 03:57
@LeandroRocha84
Copy link
Author

Thanks for the suggestion @promag
I've updated the PR to remove the unnecessary complexity. Aside from your suggested code, I've made a small change to bitcoingui.cpp so that the UI clientModel is not cleared until the RPCExecutor thread joins. Otherwise, network events, like a new connection, that trigger a UI update would raise exceptions.

@fanquake fanquake requested a review from jonasschnelli July 17, 2018 06:42
@LeandroRocha84
Copy link
Author

Hi all, please let me know if there's anything that needs to be done to have this fix merged.
Thanks

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 24, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15894 (Remove duplicated "Error: " prefix in logs by hebasto)
  • #9849 (Qt: Network Watch tool by luke-jr)

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.

@DrahtBot DrahtBot mentioned this pull request Oct 31, 2018
@hebasto
Copy link
Member

hebasto commented Dec 5, 2018

tACK 18850903f803bba58d110d3994df18969992f383 (on Linux)
Would you squash commits?

@LeandroRocha84
Copy link
Author

All comments addressed. Commits squashed. Please let me know if there's anything.

@hebasto
Copy link
Member

hebasto commented Dec 6, 2018

re-tACK abff369 (Linux, macOS 10.13.6)

@jonasschnelli
Copy link
Contributor

@LeandroRocha84 sorry for keeping this up so long...
can you rebase once and then we try to get this merged?

@LeandroRocha84
Copy link
Author

Thanks @jonasschnelli I'm working on solving the conflicts after the rebase.
The order change in fd6d499 breaks the solution in this PR as it makes the QEventLoop.exec returns right away. I've confirmed that the bug this PR intends to solve is still reproducible; the shutdown screen is frozen/blocked when we have a long running RPC command.
I'm going to spend some time this weekend to find out how exactly the order change I linked affects the QEventLoop.

Adding @promag as he might have some insight.

@LeandroRocha84 LeandroRocha84 force-pushed the qt-shutdown-13217 branch 2 times, most recently from 59ebf17 to a302c99 Compare April 20, 2019 01:03
@LeandroRocha84
Copy link
Author

Conflicts resolved, rebase completed. I've tested the fix on linux.
@jonasschnelli please let me know if there's anything else I can do to get this pull request completed.
Thank you.

@LeandroRocha84 LeandroRocha84 force-pushed the qt-shutdown-13217 branch 4 times, most recently from 937e77a to c42788e Compare May 5, 2019 21:04
@DrahtBot
Copy link
Contributor

Needs rebase

@DrahtBot
Copy link
Contributor

There hasn't been much activity lately and the patch still needs rebase, so I am closing this for now. Please let me know when you want to continue working on this, so the pull request can be re-opened.

@DrahtBot DrahtBot closed this Sep 30, 2019
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants