Fedora 11 下Qt程序报错问题求解

自强不息00001 2013-01-09 11:09:44
Qt程序会在运行一定时间后报错,时间不确定,每次报错的位置都不定,出现过三次报错现象为下图所示,请大神帮忙解决下



...全文
181 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinjianxinxh 2013-01-25
  • 打赏
  • 举报
回复
引用 8 楼 ren913458653 的回复:
错误报在下面这些函数中的 int CLS_DBManage::GetCurrentSign(int _iCurrentLogID, int _CSZPChannelID, int _iKaKouMode) { if(!m_blConnected) return -1; int iCurrentSign = 0; try { ……
兄弟你不把整个工程发出来 真不好找
haltwang 2013-01-25
  • 打赏
  • 举报
回复
设断电应该能看出死在哪一行吧
自强不息00001 2013-01-25
  • 打赏
  • 举报
回复
引用 7 楼 haltwang 的回复:
楼主断点调试,找出死的地方,把相关代码上出来吧
帮忙看下吧
自强不息00001 2013-01-23
  • 打赏
  • 举报
回复
错误报在下面这些函数中的 int CLS_DBManage::GetCurrentSign(int _iCurrentLogID, int _CSZPChannelID, int _iKaKouMode) { if(!m_blConnected) return -1; int iCurrentSign = 0; try { char pcSQL[512] = {0}; qDebug()<<"[CLS_DBManage:GetCurrentSign]: &pcSQL is "<<&pcSQL; if(1 == _iKaKouMode)//change lml { snprintf(pcSQL, sizeof(pcSQL),"SELECT LOG_ID from TAB_CAPLOG where (ALARM_TYPE = 7624 OR ALARM_TYPE = 7623 OR ALARM_TYPE = 7622 OR ALARM_TYPE = 1303 OR ALARM_TYPE = 7322) and CHANNEL_ID = %d and LOG_ID = %d", _CSZPChannelID, _iCurrentLogID); } else if(0 == _iKaKouMode) { snprintf(pcSQL, sizeof(pcSQL),"SELECT LOG_ID from TAB_CAPLOG where ALARM_TYPE = 0 and CHANNEL_ID = %d and LOG_ID = %d", _CSZPChannelID, _iCurrentLogID); } qDebug()<<"[CLS_DBManage:GetCurrentSign]: pcSQL is "<<pcSQL; pthread_mutex_lock(&m_DBLock); std::auto_ptr< sql::Statement > stmtCurrent(m_pConnection->createStatement()); qDebug()<<"[CLS_DBManage:GetCurrentSign]: &stmtCurrent is "<<&stmtCurrent; std::auto_ptr< sql::ResultSet > resCurrent(stmtCurrent->executeQuery( pcSQL ) ); qDebug()<<"[CLS_DBManage:GetCurrentSign]: &resCurrent is "<<&resCurrent; while(resCurrent->next()) { iCurrentSign ++; } pthread_mutex_unlock(&m_DBLock); } catch(sql::SQLException& e) { pthread_mutex_unlock(&m_DBLock); cpLog( LOG_ERR, "CLS_DBManage::GetCurrentSign error:%s", e.what()); RepairInsertErr(e.what()); StartDataBase(g_strDatabaseName); return -1; } return iCurrentSign; } int CLS_DBManage::GetPreSign(int _iCurrentLogID, int _CSZPChannelID, int _iKaKouMode) { if(!m_blConnected) return -1; int iPreSign = 0; try { char pcSQL[512] = {0}; qDebug()<<"[CLS_DBManage:GetPreSign]: &pcSQL is "<<&pcSQL; if(1 == _iKaKouMode) { snprintf(pcSQL, sizeof(pcSQL),"SELECT LOG_ID from TAB_CAPLOG where (ALARM_TYPE = 7624 OR ALARM_TYPE = 7623 OR ALARM_TYPE = 7622 OR ALARM_TYPE = 1303 OR ALARM_TYPE = 7322) and CHANNEL_ID = %d and LOG_ID < %d limit 1", _CSZPChannelID, _iCurrentLogID); } else if(0 == _iKaKouMode) { snprintf(pcSQL, sizeof(pcSQL),"SELECT LOG_ID from TAB_CAPLOG where ALARM_TYPE = 0 and CHANNEL_ID = %d and LOG_ID < %d limit 1", _CSZPChannelID, _iCurrentLogID); } qDebug()<<"[CLS_DBManage:GetPreSign]: pcSQL is "<<pcSQL; pthread_mutex_lock(&m_DBLock); std::auto_ptr< sql::Statement > stmtPre(m_pConnection->createStatement()); qDebug()<<"[CLS_DBManage:GetPreSign]: &stmtPre is "<<&stmtPre; std::auto_ptr< sql::ResultSet > resPre(stmtPre->executeQuery( pcSQL ) ); qDebug()<<"[CLS_DBManage:GetPreSign]: &resPre is "<<&resPre; while(resPre->next()) { iPreSign ++; } pthread_mutex_unlock(&m_DBLock); } catch(sql::SQLException& e) { pthread_mutex_unlock(&m_DBLock); cpLog( LOG_ERR, "CLS_DBManage::GetPreSign error:%s", e.what()); RepairInsertErr(e.what()); StartDataBase(g_strDatabaseName); return -1; } return iPreSign; } int CLS_DBManage::GetNextSign(int _iCurrentLogID, int _CSZPChannelID, int _iKaKouMode) { if(!m_blConnected) return -1; int iNextSign = 0; try { char pcSQL[512] = {0}; qDebug()<<"[CLS_DBManage:GetPreSign]: &pcSQL is "<<&pcSQL; if(1 == _iKaKouMode) { snprintf(pcSQL, sizeof(pcSQL),"SELECT LOG_ID from TAB_CAPLOG where (ALARM_TYPE = 7624 OR ALARM_TYPE = 7623 OR ALARM_TYPE = 7622 OR ALARM_TYPE = 1303 OR ALARM_TYPE = 7322) and CHANNEL_ID = %d and LOG_ID > %d limit 1", _CSZPChannelID, _iCurrentLogID); } else if(0 == _iKaKouMode) { snprintf(pcSQL, sizeof(pcSQL),"SELECT LOG_ID from TAB_CAPLOG where ALARM_TYPE = 0 and CHANNEL_ID = %d and LOG_ID > %d limit 1", _CSZPChannelID, _iCurrentLogID); } qDebug()<<"[CLS_DBManage:GetPreSign]: pcSQL is "<<pcSQL; pthread_mutex_lock(&m_DBLock); std::auto_ptr< sql::Statement > stmtNext(m_pConnection->createStatement()); qDebug()<<"[CLS_DBManage:GetPreSign]: &stmtNext is "<<&stmtNext; std::auto_ptr< sql::ResultSet > resNext(stmtNext->executeQuery( pcSQL ) ); qDebug()<<"[CLS_DBManage:GetPreSign]: &resNext is "<<&resNext; while(resNext->next()) { iNextSign ++; } pthread_mutex_unlock(&m_DBLock); } catch(sql::SQLException& e) { pthread_mutex_unlock(&m_DBLock); cpLog( LOG_ERR, "CLS_DBManage::GetNextSign error:%s", e.what()); RepairInsertErr(e.what()); StartDataBase(g_strDatabaseName); return -1; } return iNextSign; } int CLS_DBManage::GetInfoForUpdateBtnState(int _iCurrentLogID, int _CSZPChannelID, int _iKaKouMode) { int iRet = -1; try { if(0 == GetCurrentSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode)) { iRet = 0; } else if((0 == GetPreSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode)) \ && (0 == GetNextSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode))) { iRet = 1; } else if((GetPreSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode) > 0) \ && (0 == GetNextSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode))) { iRet = 2; } else if((0 == GetPreSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode)) \ && (GetNextSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode) > 0)) { iRet = 3; } else if((GetPreSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode) > 0) \ && (GetNextSign(_iCurrentLogID, _CSZPChannelID, _iKaKouMode) > 0)) { iRet = 4; } } catch(sql::SQLException& e) { pthread_mutex_unlock(&m_DBLock); // cpLog( LOG_ERR, "CLS_DBManage::HasCurrentLog error:%s", e.what()); RepairInsertErr(e.what()); StartDataBase(g_strDatabaseName); return -1; } return iRet; }
haltwang 2013-01-23
  • 打赏
  • 举报
回复
楼主断点调试,找出死的地方,把相关代码上出来吧
jinjianxinxh 2013-01-23
  • 打赏
  • 举报
回复
引用 5 楼 morris88 的回复:
找找什么地方出现了野指针吧?
正解,曾经碰到过这类问题,花了三天时间
morris88 2013-01-22
  • 打赏
  • 举报
回复
找找什么地方出现了野指针吧?
jinjianxinxh 2013-01-22
  • 打赏
  • 举报
回复
多调试调试 找找规律 总会找到的,如果是单线程的估计好一点,如果是多线程的楼主就慢慢找吧
自强不息00001 2013-01-22
  • 打赏
  • 举报
回复
引用 2 楼 jinjianxinxh 的回复:
这种错误只能多调试,找规律了 指着别人找到错误是不可能的
程序出现错误概率比较小,每次出现都要很长时间。能给一些调试的建议吗?
jinjianxinxh 2013-01-22
  • 打赏
  • 举报
回复
这种错误只能多调试,找规律了 指着别人找到错误是不可能的
自强不息00001 2013-01-22
  • 打赏
  • 举报
回复
没有人帮忙看下么

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧