应用程序验证程序[应用程序在关闭时崩溃] [英] Application Verifier [ Application crashing on Close ]

查看:98
本文介绍了应用程序验证程序[应用程序在关闭时崩溃]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是用VC ++创建的应用程序,必须使用AppVerifier对其进行验证.
当我使用AppVerifier测试我的应用程序时,当我关闭应用程序窗口时,应用程序崩溃.我已经调试了应用程序,并从堆栈跟踪中了解到它在最后一个称为析构函数的程序中崩溃了,但是其中没有任何代码.
如果有人发现类似问题,请发表评论,如果有人有任何想法,请帮助我找到解决方案.

I created my application in VC++ and I have to verify my it using AppVerifier.
When I am testing my application with AppVerifier the application crashes when I am closing the application window. I have debugged my application and from the stack trace I came to know it''s crashing in the last called destructor, but that one doesn''t have any code in it.
If anyone is observing similar problems please respond with a comment and anyone having some idea please help me finding a solution to this.

Thanks in advance!

推荐答案

C ++编译器会将自己的语句添加到析构函数中,以破坏属于类类型的任何成员变量.

考虑一下:
The C++ compiler will add its own statements to the destructor to destruct any member variables that are a class type.

Consider this:
class A {
	public:
		A() { m_szMessage = new char[10]; }
		~A() { delete []m_szMessage; }
	private:
		char *m_szMessage;
};

class B {
	public:
		B() { /*A::A() is called here by the compiler*/ }
		~B() { /*A::~A() is called here by the compiler*/ }
	private:
		A m_clsA;
};



我怀疑您有类似的情况,其中堆栈跟踪位于B::~B()中.
如果A的析构函数被调用两次,或者以其他某种方式被调用,那么A的内存将被删除两次,那么第二次删除它将崩溃.

还有许多其他原因也会导致程序在删除内存时崩溃.
在调试模式下,编译器将检查分配的内存周围的堆,如果将11个字符写入大小为10以上的缓冲区中,则将导致调试器中断.



I suspect that you have a similar scenario where your stack trace was in B::~B().
If the destructor to A is called twice, or by some other means the memory of A is deleted twice then the 2nd time it is deleted it will crash.

There are a number of other reasons that a program may crash when deleting memory too.
When in debug mode the compiler will check the heap around the allocated memory, and if you write 11 characters into the buffer of size 10 above then this would cause the debugger to break.


谢谢堆栈跟踪.另外,生成的异常类型经常被使用.此外,由于您正在使用应用程序验证程序,因此请查看调试器输出窗口,因为验证程序将通过调试字符串告诉您问题出在哪里.在我看来,您正在释放无效的图像列表或释放了两次.
Thanks for the stack trace. Also, the exception type generated is often of use. In addition, since you''re using the application verifier look at the debugger output window as the verifier will tell you what the problem is (via debug strings). To me it looks like you''re freeing an invalid image list or freeing one twice.


这篇关于应用程序验证程序[应用程序在关闭时崩溃]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆