mfc 的出错-Debug Assertion failed! 编译提示出错

问题描述

Debug Assertion failed! 编译提示出错

当程序编译时的出错信息提示:
Debug Assertion failed!
Program: D:rgribintest.exe
File:afxcoll.inl
Line:376

在调试时的出错提示:
First-chance exception in al.exe (MFC42D.DLL): 0xC0000005: Access Violation.
First-chance exception in al.exe (MFC42D.DLL): 0xC0000005: Access Violation.
Unhandled exception in al.exe(MFC42D.DLL):0Xc0000005:AccessViolation

堆栈的出错提示信息:
CStringList::GetHead() line 376 + 38 bytes
AL! 0040fae1()
AL! 00414505()
AL! 0040dcb8()
AL! 0040df16()
AfxDlgProc(HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, unsigned int 203712) line 35 + 14 bytes
USER32! 773186ef()
USER32! 77309eb2()
USER32! 7730b98b()
USER32! 773290f9()
USER32! 773186ef()
USER32! 77318876()
USER32! 773143cf()
USER32! 773341f9()
CWnd::DefWindowProcA(unsigned int 272, unsigned int 203712, long 0) line 1000 + 32 bytes
CWnd::Default() line 249
CDialog::HandleInitDialog(unsigned int 203712, unsigned int 203712) line 621 + 8 bytes
CWnd::OnWndMsg(unsigned int 272, unsigned int 203712, long 0, long * 0x0012ec38) line 1815 + 17 bytes
CWnd::WindowProc(unsigned int 272, unsigned int 203712, long 0) line 1585 + 30 bytes
AfxCallWndProc(CWnd * 0x0012f004 {CWnd hWnd=0x000302f8}, HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, long 0) line 368
AfxWndProcBase(HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, long 0) line 220 + 21 bytes
USER32! 773186ef()
USER32! 77318876()
USER32! 77317631()

请帮帮,谢谢

解决方案

这种错误一般是操作越界了,看代码分析

解决方案二:

直接编译器调试。多看指针操作

解决方案三:

这不是编译错误,而是运行时错误。多半是指针越界造成的。如果你用的是VS,用F5调试方式运行,出错的时候可以转到出错的代码行上,然后仔细检查那一行有没有指针的问题。

解决方案四:

三位高手,谢谢了,怎样检查指针越界,我已经知道出错的地方是在这里,但不知道怎样改:
for(int i=0;i
{
** this->m_listctrl->InsertColumn(i,m_strlist[i].GetHead());** 到这里出错,即错在GetHead()这里
col_length[i]=max(col_length[i],m_strlist[i].GetHead().GetLength());
POSITION pos=m_strlist[i].FindIndex(1);
for(int j=1;pos!=NULL;j++)
{
str=m_strlist[i].GetNext(pos);
col_length[i]=max(col_length[i],str.GetLength());
}
m_listctrl->SetColumnWidth(i,col_length[i]*10);//LVSCW_AUTOSIZE_USEHEADER
}

GetHead() 在这个函数的堆栈出错提示是:

CStringList::GetHead() line 376 + 38 bytes
AL! 0040fae1()
AL! 00414505()
AL! 0040dcb8()
AL! 0040df16()
AfxDlgProc(HWND__ * 0x00021c20, unsigned int 272, unsigned int 201048, unsigned int 201048) line 35 + 14 bytes
USER32! 754b86ef()
USER32! 754a9eb2()
USER32! 754ab98b()
USER32! 754c90f9()
USER32! 754b86ef()
USER32! 754b8876()
USER32! 754b43cf()
USER32! 754d41f9()
CWnd::DefWindowProcA(unsigned int 272, unsigned int 201048, long 0) line 1000 + 32 bytes
CWnd::Default() line 249

怎样解决,谢谢

解决方案五:

m_strlist[i]这里能不能取到值,i是多少?strList最大有多少

时间: 2024-08-03 16:07:46

mfc 的出错-Debug Assertion failed! 编译提示出错的相关文章

mfc串口通信-Debug Assertion Failed 问题

问题描述 Debug Assertion Failed 问题 如上图所示:下午在之前的MFC界面上添加了MSComm控件,新建一个SetupDlg,用来设置串口参数,中间天剑相应的代码的时候,只是编译,一直没有提示类似的错误,最后F5运行的时候却出现这个问题.另外,VS2013中使用MSComm控件,相依的注册之类的我也按照网上的帖子说的做了,可还是这个问题,求各位大神帮忙,先谢过了! 解决方案 某天调试程序突然跳出以下错误: Microsoft Visual C++ Debug Library

一个c++程序,编译没错。运行后出现错误 debug assertion failed

问题描述 一个c++程序,编译没错.运行后出现错误 debug assertion failed 具体错误如图 解决方案 VC++调程序出现如下错误: Debug Assertion Failed! Program: D:wyuStuddebugwyuStud.exe File: afx.inl Line:157 可能问题:1.野指针;2.内存泄露 解决方法: 1.看一看你的程序里是不是有ASSERT()或VERIFY()语句.这两个宏是用来测试它的参数是否为真的.出现你说的,这说明你的指针或表

struct-这个代码在编译时没有错误,在运行时却弹出debug assertion failed line52

问题描述 这个代码在编译时没有错误,在运行时却弹出debug assertion failed line52 #ifndef Linkstack_H #define Linkstack_H #include using namespace std; template struct Node { T data; Nodenext; }; template class LinkStack { public: LinkStack();//{top=NULL;} ~LinkStack(); void P

MFC出现Debug assertion failed问题

问题描述 MFC出现Debug assertion failed问题 碰到一个问题,不明白错在哪里,请大神们指点一下!!! 程序目的是在主窗口触发某事件后,弹出新的窗口显示列表,不同事件列表内容不同程序大概框架如下: 在主窗口类中添加了公有成员变量m_DeviceDlg,它也是窗口类型,并且它包含一个列表控件(ListCtrl) //主窗口类定义 class CZigBeeHomeAutomationDesktopDlg : public CDialogEx { .... public: CDe

提示debug assertion failed,帮忙看看代码问题在哪里。有谢

问题描述 提示debug assertion failed,帮忙看看代码问题在哪里.有谢 // 队列模拟栈.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include using namespace std; template struct QueueNode { QueueNode*link; T data; }; template class TheStack { private: QueueNodefront; QueueNode*r

c++-WIN7C++程序在XP上运行出现Debug Assertion Failed!

问题描述 WIN7C++程序在XP上运行出现Debug Assertion Failed! 我用VS2010写了一个MFC程序,在自己跟同事的电脑上都可运行,但是在XP上运行Debug里面的exe,就会出现Debug Assertion Failed!请问是怎么回事呢? 解决方案 去win7下,把这个程序以XP兼容方式运行试试看什么情况. 解决方案二: 有指针异常等,点击重试,用编译器打开查看一下具体出错的地方 解决方案三: C++出现debug assertion failed 解决方案四:

Debug Assertion failed!

问题描述 Debug Assertion failed! 选择忽略时会有: 各位前辈能不能给点意见,简单说两句就行,谢谢! 解决方案 CE的程序?是在虚拟机还是真机运行?一定要远程调试,找到发生错误的行,调用堆栈,或者添加点文件日志输出,否则很难调试. 解决方案二: 产生上面问题的原因:1.在程序里释放了野指针:#include using namespace std;void main(){int *p ;delete p;//////////////释放野指针指向内容执行错误} ??#inc

c语言-vs2013C语言问题 debug出现debug assertion failed怎么解决?

问题描述 vs2013C语言问题 debug出现debug assertion failed怎么解决? 刚学没几天,指针什么的都还不怎么会用,然后写了个小游戏,里面用到指针来的,运行也成功了,但是debug里的那个exe文件打开不了,会出现debug assertion failed.我觉得应该是我代码写的有问题?指针没有用好? #include #include void read_board(int board[7][8]){ FILE*fptr; int i, j; fptr = fope

线程-Debug Assertion Failed! mfcwincore.cpp Line: 934 异常

问题描述 Debug Assertion Failed! mfcwincore.cpp Line: 934 异常 第一个picture control显示深度图像,如果人在要求范围内,则显示为红色.人显示红色后,在第二个picture control中显示第一个图片的二值图像,第三个picture control显示第二个图片的轮廓图,结果在刚要显示第二个和第三个图片时候就会出现异常.由于获取深度图像函数videoRun中使用了死循环,我就新建了线程,在新建的线程中运行videoRun. 异常显