vs中“Stack around the variable was corrupted”的解决方案
把 project->配置属性->c/c++->代码生成->基本运行时检查 为 默认值 就不会报本异常。具体原因正在研究中。。。
如果改为其他就有exception。
exception有时是有道理的
// step 1
STRINGC2& STRINGC2::operator += (const char x)
{
// if (x == 0) return *this;
char ptr[1]; // max is 1 digit
ptr[0] = x;
ptr[1] = '/0';
*this += ptr; // off to step 2 and back
return *this; // step 4 crash
}
这个也会导致上述exception。
问题描述:
Problem
The following error message occurs when building on Test RealTIme environment with the cvisual7 TDP?
Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted.
Cause
Stack pointer corruption is caused writing outside the allocated buffer in stack memeory.
Solution
This
kind of error is detected by setting /RTC1 compiler option from menu
Project -> Settings -> Configuration properties -> Build ->
Compiler -> Compiler flags when using TDP cvisual7 in IBM® Rational®
Test RealTime environment.. This enables stack frame run-time error
checking. For example, the following code may cause the above error messge.
#include <stdio.h>
#include <string.h>
#define BUFF_LEN 11 // 12 may fix the Run-Time Check Failure #2
int rtc_option_test(char * pStr);
int main()
{
char * myStr = "hello world";
rtc_option_test(myStr);
return 0;
}
int rtc_option_test(char * pStr)
{
char buff[BUFF_LEN];
strcpy(buff, pStr); //cause Run-Time Check Failure #2 - Stack around
//the variable 'buff' was corrupted.
return 0;
}
vs中“Stack around the variable was corrupted”的解决方案的更多相关文章
- C语言 在VS环境下一个很有意思的报错:stack around the variable was corrupted
今天做一个很简单的oj来温习下c 语言 题目如下 输入 3位正整数 输出 逆置后的正整数 代码如下: #include"stdio.h"int main(){ float h,su ...
- vs中 Stack around the variable 'XXX' was corrupted.
https://blog.csdn.net/hou09tian/article/details/75042206 把 project->配置属性->c/c++->代码生成->基 ...
- 运行时错误:“stack around the variable…was corrupted”
造冰箱的大熊猫@cnblogs 2018/11/1 引发问题的代码片段如下 WORD var; scanf ( "%d", &var ); 包含上述代码的程序,编译正常,运 ...
- 关于stack around the variable “” was corrupted问题
很坑爹的问题,异常信息表示我的缓冲区如数组越界了,可是老子明明没有越界. 解决方法:关闭vs检查代码是否越界的功能: 属性->c/c++->代码生成->基本运行时检查,改为默认值
- stack around the variable “ ” was corrupted
用scanf格式控制不当经常发生此错误. 如 short int a=10; scanf("%d",&a); 应该是%hd; 一般是越界引起的. 参看:http://bl ...
- VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法
问题 : 在用VS2008写一段代码,算法都没有问题,但是调试的时候发现出了main之后就报 Stack around the variable 'xxx' was corrupted 的错误,后来发 ...
- Run-Time Check Failure #2 Stack around the variable ‘xxx’ was corrupted
在改别人代码时,运行报错: Run-Time Check Failure #2 Stack around the variable 'buffer' was corrupted 这表明你对某变量的赋值 ...
- Stack around the variable 'szStr' was corrupted.
错误:stack around the variable “XX” was corrupted.,中文翻译就是“在变量XX周围的堆栈已损坏”. 把 project->配置属性->c/c++ ...
- c++. Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted. char cc[1024]; //此处如果索引值 ...
随机推荐
- tp框架之函数调用
1.如果要在一个方法里面调用另一个方法,可以先用A方法实例化控制器 $m = A("控制器名"); ,然后根据方法名调用 $m->方法名(可传参数); 2.自定义函数库 ( ...
- Kafka基本原理
简介 Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.Kafka是一种快速.可扩展的.设计内在就是分布式的,分区的和可复制的提交 ...
- Win10 UI动画
<Button Content="Ship via Wells, Fargo & Co." HorizontalAlignment="Center" ...
- git学习(五):克隆和推送远程仓库
这里我已经注册好了GitHub账号了 生成本地的ssh和在github上添加ssh 在本地 ssh-keygen -t rsa -C "carryhjr@gmail.com" 一路 ...
- POJ 2653 Pick-up sticks (线段相交)
题意:给你n条线段依次放到二维平面上,问最后有哪些没与前面的线段相交,即它是顶上的线段 题解:数据弱,正向纯模拟可过 但是有一个陷阱:如果我们从后面向前枚举,找与前面哪些相交,再删除前面那些相交的线段 ...
- hibernate框架int和Integer类型区别
hibernate 框架在定义实体时,int类型最好定义为Inttger类型,因为在注入时int是值类型不允许为空.
- FragmentActivity_左右滑动的碎片
test1.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...
- python学习 3笔记
merge dict def merge(defaults, override): r = {} for k, v in defaults.items(): if k in override: if ...
- 关于UnsupportedClassVersionError的错误处理
错误:Java.lang.UnsupportedClassVersionError: Bad version number in .class file 造成这种错误的原因是你的支持Tomcat运行的 ...
- Web API返回JSON数据
对Web API新手来说,不要忽略了ApiController 在web API中,方法的返回值如果是实体的话实际上是自动返回JSON数据的例如: 他的返回值就是这样的: { "Conten ...