本文主要是介绍VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
2011-04-20 wcdj
问题 :
在用VS2008写一段代码,算法都没有问题,但是调试的时候发现出了main之后就报 Stack around the variable 'xxx' was corrupted 的错误,后来发现是数组越界造成的。测试下面类似情形的代码:
出现下图 Debug Error:
Run-Time Check Failure #2 - Stack around the variable 'a' was corrupted
原因 :
Stack pointer corruption is caused writing outside the allocated buffer in stack memory.
解决方法 :
This kind of error is detected by setting /RTC1 compiler option from menu 属性页(Alt+F7) -> 配置属性 -> C++ -> 代码生成 -> 基本运行时检查
有以下几个选项:
(1) 默认值
(2) 堆栈帧 ( /RTCs )
(3) 未初始化的变量 ( /RTCsu )
(4) 两者 ( /RTC1, 等同与 /RTCsu )
(5) <从父级或项目默认设置继承>
方法1 :修改数组越界的错误。
方法2 :设置为 (1) 默认值,就不再进行 stack frame run-time error checking。
Using /RTC1 compiler option enables stack frame run-time error checking. For example, the following code may cause the above error messge.
参考 :
Stack around the variable was corrupted 解决方案
http://laokaddk.blog.51cto.com/368606/238718
stack around the variable was corrupted
http://www.cnblogs.com/hxf829/archive/2009/11/28/1659749.html
这篇关于VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!