Hello,
I'm built dash 0.11.2.22 daemon on Windows in MSVS Express, so that I could full screen debug it! Yeah, I did the videos on building the static libraries for all *coins, see
https://www.youtube.com/channel/UCytoaHvG3H1y9CnxZS819eQ.
When I succeeded, the daemon would crash erratically or sometimes popup a Windows "needs to close" message and the program would keep running! One of the network threads bombed.
Interestingly, I caught it in the full screen debugger. The boost FOREACH() was 'error-ing' (!) or a vector exception, always on the
CMasternodeMan class private member, the vector
vMasternodes.
In
masternodeman.cpp, the vector was changing while the various class methods were FOREACH-ing the vector! I kept adding
LOCK(cs); to all those methods that didn't have it already, and when I added the last one, it stopped "exception-ing"!
I actually put "assert-ish" code like this:
int CMasternodeMan::CountMasternodesAboveProtocol(int protocolVersion)
{
int
nSize = (int)vMasternodes.size(),
i = 0;
{
LOCK(cs);
BOOST_FOREACH(CMasternode& mn, vMasternodes)
{
bool
fTest = ((int)vMasternodes.size() == nSize);
#ifdef _MSC_VER
#ifdef _DEBUG
assert(fTest);
#else
if( !fTest )
releaseModeAssertionfailure( __FILE__, __LINE__, __PRETTY_FUNCTION__ );
#endif
#endif
mn.Check();
...just to see, and sure enough one of them "tripped".
And in
void CMasternodeMan::Remove(CTxIn vin)
{
LOCK(cs);
vector::iterator it = vMasternodes.begin();
while(it != vMasternodes.end())
{
if((*it).vin == vin)
{
if(fDebug)
LogPrintf(
"CMasternodeMan: Removing Masternode %s - %i now\n",
(*it).addr.ToString().c_str(), size() - 1
);
vMasternodes.erase(it);
break;
}
++it; // don't we need this???
}
}I added that final
++it;. It just seemed appropriate!?
Don't know if it's correct or not
Seems to run OK now...
Ron