-
Notifications
You must be signed in to change notification settings - Fork 1
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
Assertion failure on shutdown #6
Comments
Good news, everyone! https://www.geek.com/wp-content/uploads/2016/03/GoodNewsEveryone-625x350.jpg 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: https://github.com/shane-kerr/Mintcoin-Desktop-Wallet/tree/shutdown-assertion-failure |
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
gdb
to look at the stack that is raising this exception. This may not help, because this sort of error can happen a long way in time and space from where it was created. 😢The text was updated successfully, but these errors were encountered: