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]; //此处如果索引值 ...
随机推荐
- WPF 动画显示控件
当我们要显示一个控件的时候,不仅仅要显示这个控件,还要有动画的效果. 主要用到了DoubleAnimation类. public static void ShowAnimation(object co ...
- MD5 加密
字符串加密 // 1. 准备好一个字符串 NSString *string = @"asdasfaf"; // 2. MD5加密是基于C语言的. 所以要把这个字符串转化成C的字符串 ...
- PowerBuilder -- 字符
原文: http://blog.csdn.net/yudehui/article/details/7858505 http://blog.csdn.net/wolfalcon/article/deta ...
- 【JavaScript】 Webpack安装及文件打包
背景 最近开启一个新项目,需要对前端的各类资源文件进行打包,经过多方调研后,决定使用webpack工具.但是网上的教程多是将webpack直接作为服务器使用,而我只是想将其作为单纯的资源打包工具而已. ...
- postgresql 常用数据库命令
连接数据库, 默认的用户和数据库是postgrespsql -U user -d dbname 切换数据库,相当于MySQL的use dbname\c dbname列举数据库,相当于mysql的sho ...
- C#设置IE代理及遇到问题的解决方案
起初使用的方法是修改完一次代理之后就不能继续修改,需要重新启动一次进程才可以,最初代码是: private void ShowProxyInfo() { if (!GetProxyStatus()) ...
- linux中redis的主从
主从模式的概念请自行百度! 主服务器只执行写操作.从服务器执行读操作. 主服务器中的数据会同步到从服务器中. 在从服务器中打开redis目录中的redis.conf文件 vim /usr/local/ ...
- Scrapy shell调试网页的信息
通过scrapy shell "http://www.thinkive.cn:10000/zentaopms/www/index.php?m=user&f=login"
- Android自定义组件
[参考的原文地址] http://blog.csdn.net/l1028386804/article/details/47101387效果图: 实现方式: 一:自定义一个含有EditText和Butt ...
- git: 常用功能等
1. an very useful simple git guide link: http://rogerdudler.github.io/git-guide/index.zh.html