user-0 提问: 看不懂：windbg分析dump结果；

回复:
user: user-1
content: 引用 5 楼 luciferisnotsatan 的回复:看看是不是和这个一样 http://bbs.csdn.net/topics/340066156  多线程同时对同一个临界区调用LeaveCriticalSection  正确的代码，在拿到锁后才释放锁。也就是说，不可能出现多线程同时去Leave同一个Critical Section

user: user-1
content: 看看是不是和这个一样 http://bbs.csdn.net/topics/340066156  多线程同时对同一个临界区调用LeaveCriticalSection

user: user-2
content: 设个断点到那里调试吧。*(strData+base+i)取这个数据的时候估计崩溃了

user: user-0
content: 修改代码后运行一段时间又崩溃，通过windbg出现如下，不知原因？  0:002> !analyze -v ******************************************************************************* *                                                                             * *                        Exception Analysis                                   * *                                                                             * *******************************************************************************  *** WARNING: Unable to verify timestamp for kernel32.dll *** WARNING: Unable to verify timestamp for user32.dll Unable to load image C:\WINDOWS\system32\ole32.dll, Win32 error 0n2 *** WARNING: Unable to verify timestamp for ole32.dll *** WARNING: Unable to verify timestamp for mswsock.dll Unable to load image C:\WINDOWS\system32\ws2_32.dll, Win32 error 0n2 *** WARNING: Unable to verify timestamp for ws2_32.dll  FAULTING_IP:  ntdll!RtlpNotOwnerCriticalSection+ac 7c98e837 cc              int     3  EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff) ExceptionAddress: 7c98e837 (ntdll!RtlpNotOwnerCriticalSection+0x000000ac)    ExceptionCode: c0000264   ExceptionFlags: 00000001 NumberParameters: 0  BUGCHECK_STR:  c0000264  DEFAULT_BUCKET_ID:  APPLICATION_FAULT  PROCESS_NAME:  energyCalc_ZL.exe  ERROR_CODE: (NTSTATUS) 0xc0000264 - {  LAST_CONTROL_TRANSFER:  from 004411a0 to 7c98e837  STACK_TEXT:   0177f83c 004411a0 004411a4 00000000 7c83690d ntdll!RtlpNotOwnerCriticalSection+0xac 0177f868 7c97b1d0 004411a0 0177f88c 00000001 energyCalc_ZL!CriticalSection 0177f880 0040200e 004411a0 00000000 00000000 ntdll!RtlLeaveCriticalSection+0x34 0177ffb8 7c824829 00000001 00000000 00000000 energyCalc_ZL!WorkerThread+0x22e [d:\anyjl_second\±àÂë\06Íê³ÉÀý³ÌÄ£ÐÍ\energycalc\gastab0.c @ 286] 0177ffec 00000000 004010a0 00000001 00000000 kernel32!BaseThreadStart+0x34   STACK_COMMAND:  ~2s; .ecxr ; kb  FOLLOWUP_IP:  energyCalc_ZL!CriticalSection+0 004411a0 ??              ???  SYMBOL_STACK_INDEX:  1  SYMBOL_NAME:  energyCalc_ZL!CriticalSection+0  FOLLOWUP_NAME:  MachineOwner  MODULE_NAME: energyCalc_ZL  IMAGE_NAME:  energyCalc_ZL.exe  DEBUG_FLR_IMAGE_TIMESTAMP:  54842b35  FAULTING_THREAD:  00000288  FAILURE_BUCKET_ID:  c0000264_energyCalc_ZL!CriticalSection+0  BUCKET_ID:  c0000264_energyCalc_ZL!CriticalSection+0  Followup: MachineOwner ---------

user: user-3
content: 有时不将“调用函数名字＋各参数值，进入函数后各参数值，中间变量值，退出函数前准备返回的值，返回函数到调用处后函数名字＋各参数值＋返回值”这些信息写日志到文件中是无论如何也发现不了问题在哪里的，包括捕获各种异常、写日志到屏幕、单步或设断点或生成core文件、……这些方法都不行！ 写日志到文件参考下面： #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef WIN32     #include <windows.h>     #include <io.h> #else     #include <unistd.h>     #include <sys/time.h>     #include <pthread.h>     #define  CRITICAL_SECTION   pthread_mutex_t     #define  _vsnprintf         vsnprintf #endif //Log{ #define MAXLOGSIZE 20000000 #define MAXLINSIZE 16000 #include <time.h> #include <sys/timeb.h> #include <stdarg.h> char logfilename1[]="MyLog1.log"; char logfilename2[]="MyLog2.log"; static char logstr[MAXLINSIZE+1]; char datestr[16]; char timestr[16]; char mss[4]; CRITICAL_SECTION cs_log; FILE *flog; #ifdef WIN32 void Lock(CRITICAL_SECTION *l) {     EnterCriticalSection(l); } void Unlock(CRITICAL_SECTION *l) {     LeaveCriticalSection(l); } #else void Lock(CRITICAL_SECTION *l) {     pthread_mutex_lock(l); } void Unlock(CRITICAL_SECTION *l) {     pthread_mutex_unlock(l); } #endif void LogV(const char *pszFmt,va_list argp) {     struct tm *now;     struct timeb tb;      if (NULL==pszFmt||0==pszFmt[0]) return;     _vsnprintf(logstr,MAXLINSIZE,pszFmt,argp);     ftime(&tb);     now=localtime(&tb.time);     sprintf(datestr,"%04d-%02d-%02d",now->tm_year+1900,now->tm_mon+1,now->tm_mday);     sprintf(timestr,"%02d:%02d:%02d",now->tm_hour     ,now->tm_min  ,now->tm_sec );     sprintf(mss,"%03d",tb.millitm);     printf("%s %s.%s %s",datestr,timestr,mss,logstr);     flog=fopen(logfilename1,"a");     if (NULL!=flog) {         fprintf(flog,"%s %s.%s %s",datestr,timestr,mss,logstr);         if (ftell(flog)>MAXLOGSIZE) {             fclose(flog);             if (rename(logfilename1,logfilename2)) {                 remove(logfilename2);                 rename(logfilename1,logfilename2);             }         } else {             fclose(flog);         }     } } void Log(const char *pszFmt,...) {     va_list argp;      Lock(&cs_log);     va_start(argp,pszFmt);     LogV(pszFmt,argp);     va_end(argp);     Unlock(&cs_log); } //Log} int main(int argc,char * argv[]) {     int i; #ifdef WIN32     InitializeCriticalSection(&cs_log); #else     pthread_mutex_init(&cs_log,NULL); #endif     for (i=0;i<10000;i++) {         Log("This is a Log %04d from FILE:%s LINE:%d\n",i, __FILE__, __LINE__);     } #ifdef WIN32     DeleteCriticalSection(&cs_log); #else     pthread_mutex_destroy(&cs_log); #endif     return 0; } //1-78行添加到你带main的.c或.cpp的那个文件的最前面 //81-85行添加到你的main函数开头 //89-93行添加到你的main函数结束前 //在要写LOG的地方仿照第87行的写法写LOG到文件MyLog1.log中

user: user-4
content: ExceptionCode: c0000005 (Access violation)

user: user-0
content: windbg跳到源码的函数：