我遇到了访问冲突,我无法调试。
我似乎在CRT调用_CrtCheckMemory
内部遇到某种递归错误。
以下是调用堆栈(底部 - >顶部),其中...
只是删除重复的消息。
msvcr100d.dll!__chkstk() Unknown
msvcr100d.dll!_VCrtDbgReportA(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 252 C
msvcr100d.dll!_CrtDbgReportV(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 242 C
msvcr100d.dll!_CrtDbgReport(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, ...) Line 258 C
msvcr100d.dll!_CrtCheckMemory() Line 1817 C++
msvcr100d.dll!_heap_alloc_dbg_impl(unsigned __int64 nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 383 C++
msvcr100d.dll!_nh_malloc_dbg_impl(unsigned __int64 nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239 C++
msvcr100d.dll!_calloc_dbg_impl(unsigned __int64 nNum, unsigned __int64 nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 601 C++
msvcr100d.dll!_getptd_noexit() Line 470 C
msvcr100d.dll!_XcptFilter(unsigned long xcptnum, _EXCEPTION_POINTERS * pxcptinfoptrs) Line 202 C
msvcr100d.dll!_callthreadstartex$filt$0() Line 316 C
msvcr100d.dll!__C_specific_handler(_EXCEPTION_RECORD * ExceptionRecord, void * EstablisherFrame, _CONTEXT * ContextRecord, _DISPATCHER_CONTEXT * DispatcherContext) C
ntdll.dll!0000000077989d0d() Unknown
ntdll.dll!00000000779791af() Unknown
ntdll.dll!00000000779b1278() Unknown
msvcr100d.dll!__chkstk() Unknown
...
msvcr100d.dll!_VCrtDbgReportA(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 298 C
msvcr100d.dll!_CrtDbgReportV(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 242 C
msvcr100d.dll!_CrtDbgReport(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, ...) Line 258 C
msvcr100d.dll!_CrtCheckMemory() Line 1817 C++
msvcr100d.dll!_heap_alloc_dbg_impl(unsigned __int64 nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 383 C++
msvcr100d.dll!_nh_malloc_dbg_impl(unsigned __int64 nSize, int nhFlag, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 239 C++
msvcr100d.dll!_calloc_dbg_impl(unsigned __int64 nNum, unsigned __int64 nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 601 C++
msvcr100d.dll!_getptd_noexit() Line 470 C
msvcr100d.dll!_errno() Line 280 C
msvcr100d.dll!_VCrtDbgReportA(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 298 C
msvcr100d.dll!_CrtDbgReportV(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 242 C
msvcr100d.dll!_CrtDbgReport(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, ...) Line 258 C
msvcr100d.dll!_CrtCheckMemory() Line 1817 C++
msvcr100d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1288 C++
msvcr100d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 C++
msvcr100d.dll!_freefls(void * data) Line 622 C
msvcr100d.dll!_freeptd(_tiddata * ptd) Line 683 C
msvcr100d.dll!_endthreadex(unsigned int retcode) Line 365 C
msvcr100d.dll!_callthreadstartex() Line 315 C
msvcr100d.dll!_threadstartex(void * ptd) Line 297 C
kernel32.dll!000000007729652d() Unknown
ntdll.dll!000000007798c521() Unknown
知道可能导致此问题或建议如何进行调试吗?
答案 0 :(得分:4)
嗯,这有点悲惨。它正在尝试生成诊断信息,告诉您堆已损坏。报告代码尝试获取 errno 的值以显示它,但这是一个按需分配的静态CRT变量。所以它分配内存。哪个死了,堆已经损坏了。这会触发诊断,告诉您堆已损坏。你可以猜测其余部分,这种情况一直持续到堆栈耗尽为止。
一种解决方法是将这段代码添加到main(或线程)的开头:
int dummy = errno;
所以CRT在堆被破坏之前分配内存。你仍然必须找到腐败的原因。
答案 1 :(得分:2)
实际上你的主要问题是你已经损坏了你的内存,现在当程序要退出时,它想要释放其内部分配的内存(用于存储每个线程数据的内存),并且由于你使用的是调试版本,它会检查它的内存和理解失败并开始显示一个断言窗口,现在当它想要显示它的断言窗口时,它需要分配一些内存并使用内存分配例程(malloc
将转换为malloc_dbg
在这种情况下)分配其所需的内存和malloc_dbg
检查内存状态并了解内存损坏并尝试再次显示一个断言窗口,并重复此过程。请检查您的动态内存分配(甚至检查静态定义的数组以进行覆盖)以解决内存损坏并且堆栈溢出将自动解决