织梦CMS - 轻松建站从此开始!

罗索

Run-Time Check Failure #2 - Stack around the variable 'x

罗索客 发布于 2007-08-17 19:13 点击:次 
TestRT: Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted. The following error message occurs when building on Test RealTIme environment with the cvisual7 TDP?
TAG:

from http://www-1.ibm.com/support/docview.wss?uid=swg21211974

TestRT: Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted.
Technote (FAQ)

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;
}

(佚名)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/200708/6767.html]
本文出处:ibm.com 作者:佚名
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
相关文章
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容