Run-Time Check Failure #N

环境:Visual Studio Team Suite 2005
类型:Debug

以下是简化代码,出现让人摸不着头脑的Run-Time Check Failure,具体原因还在研究中,有结果会公布上来,N久没写博客了,太忙了。。。

代码1

#include 'stdafx.h' void malice() { printf('Hey,you're been attacked.\n'); } void foo() { int *ret; ret=(int*)&ret+2; (*ret)=(int)malice; } int _tmain(int argc, _TCHAR* argv[]) { foo(); return 0; }

运行后出现:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.


代码2

#include 'stdafx.h' void foo() { int var[2]; var[2] = 0; } int _tmain(int argc, _TCHAR* argv[]) { foo(); return 0; }

运行后出现:
Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted.

#include 'stdafx.h' #include <iostream> using namespace std; int a,b; int _tmain(int argc, _TCHAR* argv[]) { int c; cout<<a<<'\n'; cout<<b<<'\n'; cout<<c<<'\n'; return 0; }

运行后出现:
Run-Time Check Failure #3 - The variable 'c' is being used without being defined.

posted on 2008-01-20 22:27  三毛  阅读(3119)  评论(1编辑  收藏  举报

导航