Run-Time Check Failure #2 - Stack around the variable 'ucPriKey' was corrupt
来源:互联网 发布:联想s800软件 编辑:程序博客网 时间:2024/06/16 00:52
Run-Time Check Failure #2
一般是栈被破坏,你的代码可能有缓冲区溢出一类的问题。
Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
摘要:
简介VC++.NET编译新功能,运行时错误检查,编译选项 (/RTC1, equiv. to /RTCsu)
最近把一个别人早期在VC 6下编写的一个服务移植到VC 7.1 (.NET 2003)时,突然跳出
好些运行时错误提示。
经过查询编译器和出错说明,发现了编译器的这一新特性,并修正了代码隐患:
//someheadefile.h
typedef struct tarSomeMessagePack
{
char moibleNumber[20];
....
}SomeMessagePack_T,*SomeMessagePack_Ptr;
细心的开发者可能已经发现,这里使用字符串数组下标越界了。即mobileNumber[]有效元素
下标为0到19,mobileNumber[20]是非法的。在VC 6下,编译运行并没有处任何问题,这也结
构体在内存字节对齐也有关系,实际上,mobileNumber[]在默认与8字节对齐的环境下编译链
接的,因此,后4个bit也不会被系统用到,即mobileNumber[20],mobileNumber[21],
mobileNumber[22],mobileNumber[23]系统把它空着。
尽管系统运行同几年都很正常,但
strncpy(pack.mobileNumber," ",20);
这样的代码也是危险的代码,要是有一天,把这个结构体字节对齐方式改为1,那么程序一定
在这里崩溃。
VC7.1为我们提供了一种机制,在编译选项中,增加(/RTC1, equiv. to /RTCsu)项选。当程序
运行到这里的时候,即会向我们报告这一错误。
查看相关文档,了解了这一块代码的真实意图后,我把代码改为
strncpy(pack.mobileNumber," ",19);
这一问题消失。
//someimplement.cpp
strncpy(pack.mobileNumber," ",20);
郑注:这就是一些变量的内存访问出错造成的,而且在错误对话框中明显的提出了是哪个变量访问出错,可以查这个变量得到结果。典型的错误:如定义了一个TCHAR Code[1];,结果在使用中使用到了Code[1],就产生了这个错误
Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
摘要:
简介VC++.NET编译新功能,运行时错误检查,编译选项 (/RTC1, equiv. to /RTCsu)
最近把一个别人早期在VC 6下编写的一个服务移植到VC 7.1 (.NET 2003)时,突然跳出
好些运行时错误提示。
经过查询编译器和出错说明,发现了编译器的这一新特性,并修正了代码隐患:
//someheadefile.h
typedef struct tarSomeMessagePack
{
}SomeMessagePack_T,*SomeMessagePack_Ptr;
细心的开发者可能已经发现,这里使用字符串数组下标越界了。即mobileNumber[]有效元素
下标为0到19,mobileNumber[20]是非法的。在VC 6下,编译运行并没有处任何问题,这也结
构体在内存字节对齐也有关系,实际上,mobileNumber[]在默认与8字节对齐的环境下编译链
接的,因此,后4个bit也不会被系统用到,即mobileNumber[20],mobileNumber[21],
mobileNumber[22],mobileNumber[23]系统把它空着。
尽管系统运行同几年都很正常,但
strncpy(pack.mobileNumber," ",20);
这样的代码也是危险的代码,要是有一天,把这个结构体字节对齐方式改为1,那么程序一定
在这里崩溃。
VC7.1为我们提供了一种机制,在编译选项中,增加(/RTC1, equiv. to /RTCsu)项选。当程序
运行到这里的时候,即会向我们报告这一错误。
查看相关文档,了解了这一块代码的真实意图后,我把代码改为
strncpy(pack.mobileNumber," ",19);
这一问题消失。
//someimplement.cpp
strncpy(pack.mobileNumber," ",20);
郑注:这就是一些变量的内存访问出错造成的,而且在错误对话框中明显的提出了是哪个变量访问出错,可以查这个变量得到结果。典型的错误:如定义了一个TCHAR Code[1];,结果在使用中使用到了Code[1],就产生了这个错误
- Run-Time Check Failure #2 - Stack around the variable 'ucPriKey' was corrupt
- run-time check failure,stack around the variable “ ” was corrupted
- Run-Time Check Failure #2 - Stack around the variable
- 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(待解决)
- VS2008中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.
- 一例 Run-Time Check Failure #2 - Stack around the variable 'ID' was corrupted.的解决
- Run-Time Check Failure #2 - Stack around the variable 'a' was corrupted 解决方法
- ARM与X86 CPU架构对比区别
- 啦啦啦,开张了。。。。
- 用数据管理过程(1)——以数据“感知”项目状况
- MySQL5安装
- 内核调用用户空间可执行文件以及潜在问题分析
- Run-Time Check Failure #2 - Stack around the variable 'ucPriKey' was corrupt
- 桌面截图程序
- U3D资源动态加载异步方案探究
- 利用WinDriver开发PCI设备驱动程序
- .h头文件 .lib库文件 .dll动态库文件之间的关系
- XCode5使用低版本SDK
- Spring与RMI集成实现远程访问
- OpenCV与GDAL混合编程处理遥感图像
- 如何使用android的ndk建立native的开发环境