使用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
...全文
79 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧