使用Purify for Windows时出现的问题(紧急!)
**************************************************************************
#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
#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
...全文
相关推荐
purify plus v7.0 for windows part2(含破解)
purify plus v7.0 for windows part2(含破解)只能用于xp和visual studio 2005的支持,win7支持不好,请勿使用。
使用Purify检查内存泄漏
对于许多开发团队来说,Purify已证明是一种不可或缺的工具,能够帮助他们快速定位并修复那些难以发现的内存问题。
如何使用purify调试程序.pdf
这允许开发者设置断点或触发条件,当特定内存区域的状态发生变化时触发。结合调试器使用,这种方法可以更有效地定位导致内存问题的代码路径。
Purify - Rational的测试工具.txt 使用说明
动态分析**Purify支持动态分析,能够在程序运行时捕捉异常行为,如内存访问违规、资源争用等,并提供详细的错误报告,便于问题定位。**3.
purify plus 使用手册
- **PureCoverage 集成**:介绍 Purify 与 PureCoverage 结合使用时的最佳实践,帮助用户更全面地评估代码质量和性能。


