您知道标题中描述的这种情况的可能原因是什么?这是我的 bt 的样子:
#0 0x00a40089 在?? () #1 0x09e3fac0 在 ?? () #2 0x09e34f30 在?? () #3 0xb7ef9074 在?? () #4 0xb7ef9200 在?? () #5 0xb7ef9028 在?? () #6 0x081d45a0 在 LogFile::Flush () #7 0x081d45a0 在 LogFile::Flush () #8 0x081d46e0 在 LogFile::Close () #9 0x081d4dbf 在 LogFile::OpenLogFile () #10 0x081d4eb9 在 LogFile::PerformPeriodicalFlush () #11 0x081d4fca 在 LogFile::StoreRecord () #12 0x081d50c2 在 LogFile::StoreRecord ()
它给了我Program terminated with signal 11, Segmentation fault.
fflush() 的包装很简单,什么都不做,只是调用fflash
并检查错误(如果返回的代码是 <0 )。所以,我猜段错误是由fflash
. 或者它可能在其他地方,因为??
在堆栈的顶部?
操作系统:RHEL5;gcc 版本 3.4.6 20060404(红帽 3.4.6-3);使用 gdb 进行调试,其中包含最大调试信息的原始 exe。
我知道磁盘上没有空间的段错误,但这不是这种情况(因为我有一个应用程序的看门狗,它再次重新启动程序并且一切正常)。
任何想法都会有所帮助。谢谢。
编辑
void LogFile::PerformPeriodicalFlush( const utils::dt::TimeStamp& tsNow )
throw( LibCException )
{
m_tsLastPeriodicalCheck = tsNow;
struct stat LogFileStat;
int nResult = stat( m_sCurrentFullFileName.c_str(), &LogFileStat );
if ( 0 == nResult && S_ISREG( LogFileStat.st_mode ) )
{
//we successfuly stated the file, so it exists. We can safely perform
//a flush.
try
{
Flush();
return;
}
catch ( LibCException& )
{
OpenLogFile( tsNow );
return;
}
}
else
{
OpenLogFile( tsNow );
}
}
void RotatingLogFile::Flush() throw( object::LibCException )
{
if ( m_pFile != NULL )
{
if ( fflush( m_pFile ) (less_than) 0 )
{
throw object::LibCException();
}
}
}