我以前遇到过和你一样的错误,错误就是DEBUG时不出错,运行时到函数的最后结束时的大括号处出错。错误原因有以下几点:
1.你可能在你的函数里滥用不确定参数的函数,比如printf("...",...)因为参数个数可以不确定。
2.你的网络通信逻辑有误,或者过多重复以下操作:缓冲区有没有接收的数据而关闭了SOCKET,然后重新创建SOCKET。
1.你可能在你的函数里滥用不确定参数的函数,比如printf("...",...)因为参数个数可以不确定。
2.你的网络通信逻辑有误,或者过多重复以下操作:缓冲区有没有接收的数据而关闭了SOCKET,然后重新创建SOCKET。
catch(...)捕捉不到吗?
或者把代码贴出来让在下也学习学习呀.
1的错误不存在
2倒是有些可能,因为我每次是读不同的数据(量很大),
然后走不同的逻辑路线,有时会出这种错误,
可是我的代码实在太长,我不可能跟踪到底运行了什么逻辑(当然逻辑本身无错,就是这种情况),所以特别麻烦!!!to zhang1000(多一个零)
不好意思,是在太长,不好贴
请各位帮帮忙
我这有一个dll. 专门跟踪程序崩溃,并保存信息到一个文件文件在你的工程中,粘上下列代码, 运行程序时,把dll拷贝至同一目录下.运行.如果程序崩溃,会在当前目录下生成一下XXX.crash文件,用记事本打开这个文件,里面有出错的源文件哪一条语句#define GSTSO_PARAMS 0x01
#define GSTSO_MODULE 0x02
#define GSTSO_SYMBOL 0x04
#define GSTSO_SRCLINE 0x08static BOOL (__stdcall * pSetCrashHandlerFilter) (LONG (__stdcall *pFn)(EXCEPTION_POINTERS*));
static LPCTSTR (__stdcall * pGetFaultReason) ( EXCEPTION_POINTERS * pExPtrs );
static LPCTSTR (__stdcall * pGetRegisterString) ( EXCEPTION_POINTERS * pExPtrs );
static LPCTSTR (__stdcall * pGetFirstStackTraceString) (DWORD, EXCEPTION_POINTERS*);
static LPCTSTR (__stdcall * pGetNextStackTraceString) (DWORD, EXCEPTION_POINTERS*);static LONG __stdcall ExcepCallBack ( EXCEPTION_POINTERS * pExPtrs )
{
DWORD dwOpts;
CString Debugmsg; dwOpts = GSTSO_PARAMS | GSTSO_MODULE | GSTSO_SYMBOL | GSTSO_SRCLINE; CString FaultReason(pGetFaultReason (pExPtrs ));
CString RegisterString(pGetRegisterString(pExPtrs)); Debugmsg.Format("%s\n\n%s\n\n", FaultReason, RegisterString);
CString str;
const char * szBuff = pGetFirstStackTraceString ( dwOpts, pExPtrs ) ;
do
{
str.Format("%s\n\n", szBuff ) ;
Debugmsg += str;
szBuff = pGetNextStackTraceString ( dwOpts , pExPtrs ) ;
}
while ( NULL != szBuff ) ;
try
{
CStdioFile crashFile;
crashFile.Open( CTime::GetCurrentTime().Format("%m%d%H%M") +".crash",
CFile::modeCreate | CFile::modeWrite | CFile::typeText ); crashFile.WriteString(Debugmsg);
}
catch(...)
{} ::ExitProcess(5);
//return ( EXCEPTION_CONTINUE_SEARCH ) ;
return ( EXCEPTION_EXECUTE_HANDLER ) ;
}CXXXApp::CXXXApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
hCrashHandle = LoadLibrary("BugslayerUtil.dll");
if(hCrashHandle)
{
pSetCrashHandlerFilter = (BOOL (__stdcall *) (LONG (__stdcall *)(EXCEPTION_POINTERS*)))GetProcAddress(hCrashHandle, "SetCrashHandlerFilter");
pGetFaultReason = (LPCTSTR (__stdcall *) ( EXCEPTION_POINTERS*))GetProcAddress(hCrashHandle, "GetFaultReason");
pGetRegisterString = (LPCTSTR (__stdcall *) ( EXCEPTION_POINTERS*))GetProcAddress(hCrashHandle, "GetRegisterString");
pGetFirstStackTraceString = (LPCTSTR (__stdcall *)(DWORD, EXCEPTION_POINTERS*))GetProcAddress(hCrashHandle, "GetFirstStackTraceString");
pGetNextStackTraceString = (LPCTSTR (__stdcall *)(DWORD, EXCEPTION_POINTERS*))GetProcAddress(hCrashHandle, "GetNextStackTraceString");
if(!(pSetCrashHandlerFilter &&
pGetFaultReason &&
pGetRegisterString &&
pGetFirstStackTraceString &&
pGetNextStackTraceString))
{
::FreeLibrary(hCrashHandle);
hCrashHandle = NULL;
}
else
pSetCrashHandlerFilter(ExcepCallBack);
}
}10分钟以内留下你的mail