VS2008中Run-Time Check Failure#2 - Stack around the variable * was corrupted
来源:互联网 发布:linux注释#作用 编辑:程序博客网 时间:2024/06/06 08:49
VS2008创建工程,编译OK,运行结束退出主函数是弹出警告窗:
原因 :
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。
Debug过程中发现,在结构体数组中定义了字符数组
typedef struct {
char fccID[4];
unsigned long dwSize;
char fccType[4];
}HEADER;
HEADER pcmHEADER;
应用字符串拷贝函数:
strcpy(pcmHEADER.fccID,"RIFF");
strcpy(pcmHEADER.fccType,"WAVE");
在此忽略了一点,字符串拷贝时末尾要自动添加结束标识符‘\0’,而数组fccID和fccType大小只4个字节,造成越界, 所以在主函数运行结束释放堆栈时出现问题。
- VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法
- VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法
- VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法
- 浅析vs2008中 Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
- VS2008中Run-Time Check Failure#2 - Stack around the variable * was corrupted
- run-time check failure,stack around the variable “ ” was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'cz' was corrupted.
- Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'szNum' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'buf' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'cinfo' was corrupted.问题
- Run-Time Check Failure #2 - 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 'var' was corrupted
- Run-Time Check Failure #2 - Stack around the variable 'ltime' was corrupted.
- Poj-3420 Quad Tiling
- 6/6plus适配的问题
- Edit Distance -- leetcode
- 内地艺人刘雨欣气质高清杂志图片
- HOF特征
- VS2008中Run-Time Check Failure#2 - Stack around the variable * was corrupted
- ZOJ 3326 - An Awful Problem
- Thread的一些基本操作
- UVa 11388----GCD LCM
- arm-linux内核编译过程小结
- 矩阵的秩及子空间
- linux网络设备测试-----socket
- _BLOCK_TYPE_IS_VALID assertion failed
- 第六周项目二 我的数组类(深复制)