- trying to trace nig's crash (more debug info and safer code)

This commit is contained in:
Mark Vejvoda
2013-01-23 14:51:28 +00:00
parent 141f7eaa48
commit 7ecc7325ac
15 changed files with 109 additions and 54 deletions

View File

@@ -50,16 +50,26 @@ BaseThread::~BaseThread() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
MutexSafeWrapper safeMutexMasterList(&mutexMasterThreadList);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
if(masterThreadList.find(this) == masterThreadList.end()) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
char szBuf[8096]="";
snprintf(szBuf,8096,"invalid thread delete for ptr: %p",this);
throw megaglest_runtime_error(szBuf);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
masterThreadList[this]--;
if(masterThreadList[this] <= 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
masterThreadList.erase(this);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
safeMutexMasterList.ReleaseLock();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n",__FILE__,__FUNCTION__,__LINE__,uniqueID.c_str(),ret);
}
bool BaseThread::isThreadDeleted(void *ptr) {

View File

@@ -134,7 +134,8 @@ void FileCRCPreCacheThread::execute() {
new FileCRCPreCacheThread(techDataPaths,
workerTechList,
this->processTechCB);
workerThread->setUniqueID(__FILE__);
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
workerThread->setUniqueID(mutexOwnerId);
preCacheWorkerThreadList.push_back(workerThread);
workerThread->start();
@@ -368,8 +369,8 @@ SimpleTaskThread::~SimpleTaskThread() {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str());
//throw megaglest_runtime_error(ex.what());
abort();
throw megaglest_runtime_error(ex.what());
//abort();
}
}

View File

@@ -1791,8 +1791,9 @@ void ClientSocket::startBroadCastClientThread(DiscoveredServersInterface *cb) {
ClientSocket::stopBroadCastClientThread();
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
broadCastClientThread = new BroadCastClientSocketThread(cb);
broadCastClientThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
broadCastClientThread->setUniqueID(mutexOwnerId);
broadCastClientThread->start();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -2151,7 +2152,8 @@ void ServerSocket::startBroadCastThread() {
//printf("Start broadcast thread [%p]\n",broadCastThread);
broadCastThread->setUniqueID(string(__FILE__) + string("_") + string(__FUNCTION__));
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
broadCastThread->setUniqueID(mutexOwnerId);
broadCastThread->start();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);