Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Assertion failure on shutdown #6
We get an assertion failure on shutdown:
This happens on the Qt (GUI) version too.
One possible approach to fixing this would be to enable core dumps and then using
Good news, everyone!
I was able to reproduce the assertion failure and get a stack trace:
Okay, it looks like this was an issue in the Bitcoin Core that Novacoin was forked from, which MintCoin was forked from:
We don't know if the change mentioned there (switching to boost::asio deadline timers) actually fixed the problem, since the reporter didn't reply and the issue is still open, but my guess is that since we haven't seen any follow-up that it probably did.
Sadly that change is probably beyond the scope of what we want to do with the existing wallet code.
As often happens the lovely Stack Overflow site gave me a clue:
What seems to be happening is that we are exiting the program before the connection thread exits. Most likely exit() somehow starts to clean up the stack with the thread still running, trying to use the stack to store a mutex variable. We can see this if we look at the
Here we see the
The cause for this is that the code deliberately reduces the thread count before trying to connect:
vnThreadsRunning[THREAD_OPENCONNECTIONS]--; CNode* pnode = ConnectNode(addrConnect, strDest); vnThreadsRunning[THREAD_OPENCONNECTIONS]++;
Probably this was added since the default timeout for connecting to a node is 5 seconds, and someone decided that this was too long to wait.
The solution to this is simple: remove the lines of code which adjust the thread count before and after the connection attempt. The drawback is that we may have to wait 5 seconds for the program to end if it is trying to connect. I think this is a fair trade-off.
Note that this is also why changing to boost::asio fixed the problem for Bitcoin Core. The ASIO library - being asynchronous - does not block at any time, so the program can exit immediately no matter what network I/O is in progress. No trickery involved. It was a good decision.
The following branch fixes this bug: