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

brighthuang brighthuang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
**************************************************************************
#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
...全文
评论
收藏 已收藏
分享
返回顶部
brighthuang
C++ 语言 65,214 成员 250,514 内容