使用Purify for Windows时出现的问题(紧急!)

brighthuang 2004-04-30 12:23:39
**************************************************************************
#include <stdio.h>
#include <string.h>
#include <malloc.h>

int main()
{
int i, length;
char *string1 = "Hello, Windows";
char *string2 = (char*)malloc(10);

printf("%s\n", string1);

length = strlen(string2); // UMR because string2 is not initialized.

for (i = 0; string1[i] != '\0'; i++) {
string2[i] = string1[i]; // ABW's generated on this line.
}
length = strlen(string2); // ABR generated on this line.

return 0;
}
**************************************************************************

上面一段程序在cygwin中用g++编译生成a.exe,在VC中编译生成testPurify.exe
(后面简称t.exe),然后分别用Rational Purify for Windows检查内存泄漏。

t.exe的检查结果如下:(是正常的、所期望的结果)
[I] Starting Purify'd testPurify.exe at 2004-04-30 10:47:49
[I] Starting main
[W] UMR: Uninitialized memory read in strlen {1 occurrence}
[E] ABW: Array bounds write in main {4 occurrences}
[E] ABR: Array bounds read in strlen {1 occurrence}
[I] Summary of all memory leaks... {10 bytes, 1 block}
[I] Exiting with code 0 (0x00000000)
[I] Program terminated at 2004-04-30 10:47:49

a.exe的结果如下:(不正确结果)
[I] Starting Purify'd a.exe at 2004-04-30 10:48:09
[I] Starting main
[I] Summary of all memory leaks... {0 bytes, 0 blocks}
[I] Terminating thread 0x1c4
[I] Program terminated at 2004-04-30 10:48:11

a.exe在Instrumenting cygwin1.dll的时候产生了如下log:
*************************************************************************
Purify for Windows,
Copyright (C) 1992-2001 Rational Software Corporation All rights reserved.
Version 2002.05.00; Build: 4113;
WinNT 5.0 2195 Service Pack 4 Uniprocessor Free
Instrumenting:
CYGWIN1.DLL 927560 bytes

Purify: While processing file C:\cygwin\bin\CYGWIN1.DLL:
Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Note: Instrumentation repeating with 18 additional entry points.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.

Purify: Warning: Address 0x615d0000 does not appear to be in any block.
************************************************************************

问题应该是出在cygwin1.dll上,但是不知到底是怎么回事,如何解决?还请高手不吝赐教
E-mail联系:huangliang@ebupt.com
...全文
48 回复 点赞 打赏 收藏 举报
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
C++ 语言
加入

6.0w+

社区成员

C++ 语言相关问题讨论,技术干货分享,前沿动态等
申请成为版主
帖子事件
创建了帖子
2004-04-30 12:23
社区公告
暂无公告