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

pic

 

原因
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

 

 

 

 

  • 12
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值