bitcoin-core / gui

Bitcoin Core GUI staging repository
https://github.com/bitcoin/bitcoin
MIT License
604 stars 266 forks source link

Segfault in qt/clientmodel.cpp:92 on every shutdown #800

Closed maflcko closed 8 months ago

maflcko commented 9 months ago

Is there an existing issue for this?

Current behaviour

On shutdown, I get a crash in return m_node.getNodeCount(connections);

Expected behaviour

No crash

Steps to reproduce

Relevant log output

No response

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

master

Operating system and version

ubuntu

Machine specifications

No response

maflcko commented 9 months ago

The thread b-msghand is still busy in ActivateBestChainStep, the thread b-shutoff is currently joining the message handler thread in CConnman::StopThreads net.cpp:3336.

The thread bitcoin-qt is the one segfaulting.

maflcko commented 9 months ago

Steps to reproduce:

diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index ad80922c8b..d6ca01ebc4 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -989,6 +989,7 @@ void BitcoinGUI::gotoLoadPSBT(bool from_clipboard)

 void BitcoinGUI::updateNetworkState()
 {
+UninterruptibleSleep(100ms);
     int count = clientModel->getNumConnections();
     QString icon;
     switch(count)
diff --git a/src/validation.cpp b/src/validation.cpp
index 81a3c35864..c18608dcd7 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -3140,6 +3140,7 @@ bool Chainstate::ActivateBestChainStep(BlockValidationState& state, CBlockIndex*

         // Connect new blocks.
         for (CBlockIndex* pindexConnect : reverse_iterate(vpindexToConnect)) {
+        UninterruptibleSleep(3s);
             if (!ConnectTip(state, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
                 if (state.IsInvalid()) {
                     // The block violates a consensus rule.
gdb --args ./src/qt/bitcoin-qt -signet -datadir=/run/media/marco/scratch_fde/signet/ -printtoconsole  -server
...
run
while ./src/bitcoin-cli -signet -datadir=/run/media/marco/scratch_fde/signet/ setnetworkactive true && sleep 0.2 && ./src/bitcoin-cli -signet -datadir=/run/media/marco/scratch_fde/signet/ setnetworkactive false ; do true ; done
furszy commented 9 months ago

801

hebasto commented 9 months ago

801

@maflcko Does it fix the issue for you?

hebasto commented 8 months ago

Closed by https://github.com/bitcoin-core/gui/pull/801.