1

所以给定这个输出:

==80518== Invalid read of size 4
==80518==    at 0x558D: Node::ReadFolder(GFile*) (in ./ScribeRecoverMail2)
==80518==    by 0x7B61: Worker::Export(GFile*, GArray<Node*>&) (in ./ScribeRecoverMail2)
==80518==    by 0x8F7A: Worker::Main() (in ./ScribeRecoverMail2)
==80518==    by 0x142D64: ThreadEntryPoint(void*) (in /Users/matthew/Code/Scribe-Branches/v2.00/Utils/ScribeRecoverMail2/build/Debug/ScribeRecoverMail2.app/Contents/Frameworks/Lgi.framework/Versions/A/Lgi)
==80518==    by 0x47E258: _pthread_start (in /usr/lib/libSystem.B.dylib)
==80518==    by 0x47E0DD: thread_start (in /usr/lib/libSystem.B.dylib)
==80518==  Address 0x1d72f590 is 16 bytes inside a block of size 72 alloc'd
==80518==    at 0x41581: malloc (vg_replace_malloc.c:266)
==80518==    by 0x3D5616: operator new(unsigned long) (in /usr/lib/libstdc++.6.0.9.dylib)
==80518==    by 0x77A6: Worker::Scan(GFile*, GArray<Node*>&) (in ./ScribeRecoverMail2)
==80518==    by 0x8F0C: Worker::Main() (in ./ScribeRecoverMail2)
==80518==    by 0x142D64: ThreadEntryPoint(void*) (in /Users/matthew/Code/Scribe-Branches/v2.00/Utils/ScribeRecoverMail2/build/Debug/ScribeRecoverMail2.app/Contents/Frameworks/Lgi.framework/Versions/A/Lgi)
==80518==    by 0x47E258: _pthread_start (in /usr/lib/libSystem.B.dylib)
==80518==    by 0x47E0DD: thread_start (in /usr/lib/libSystem.B.dylib)
==80518== 
==80518== Invalid read of size 4
==80518==    at 0x10B70F: GFile::Read(void*, int, int) (in /Users/matthew/Code/Scribe-Branches/v2.00/Utils/ScribeRecoverMail2/build/Debug/ScribeRecoverMail2.app/Contents/Frameworks/Lgi.framework/Versions/A/Lgi)
==80518==    by 0x360E: Node::Read(GFile*, unsigned int&) (in ./ScribeRecoverMail2)
==80518==    by 0x55CF: Node::ReadFolder(GFile*) (in ./ScribeRecoverMail2)
==80518==    by 0x7B61: Worker::Export(GFile*, GArray<Node*>&) (in ./ScribeRecoverMail2)
==80518==    by 0x8F7A: Worker::Main() (in ./ScribeRecoverMail2)
==80518==    by 0x142D64: ThreadEntryPoint(void*) (in /Users/matthew/Code/Scribe-Branches/v2.00/Utils/ScribeRecoverMail2/build/Debug/ScribeRecoverMail2.app/Contents/Frameworks/Lgi.framework/Versions/A/Lgi)
==80518==    by 0x47E258: _pthread_start (in /usr/lib/libSystem.B.dylib)
==80518==    by 0x47E0DD: thread_start (in /usr/lib/libSystem.B.dylib)
==80518==  Address 0x1a198900 is 0 bytes inside a block of size 24 alloc'd
==80518==    at 0x41581: malloc (vg_replace_malloc.c:266)
==80518==    by 0x3D5616: operator new(unsigned long) (in /usr/lib/libstdc++.6.0.9.dylib)
==80518==    by 0xDFADB: GFile::GFile() (in /Users/matthew/Code/Scribe-Branches/v2.00/Utils/ScribeRecoverMail2/build/Debug/ScribeRecoverMail2.app/Contents/Frameworks/Lgi.framework/Versions/A/Lgi)
==80518==    by 0x8E4E: Worker::Main() (in ./ScribeRecoverMail2)
==80518==    by 0x142D64: ThreadEntryPoint(void*) (in /Users/matthew/Code/Scribe-Branches/v2.00/Utils/ScribeRecoverMail2/build/Debug/ScribeRecoverMail2.app/Contents/Frameworks/Lgi.framework/Versions/A/Lgi)
==80518==    by 0x47E258: _pthread_start (in /usr/lib/libSystem.B.dylib)
==80518==    by 0x47E0DD: thread_start (in /usr/lib/libSystem.B.dylib)

Valgrind 似乎在抱怨正常的日常行为。有问题的块仍然被分配,并且访问是在内存块的开始和结束内。那么为什么 valgrind 会抱怨呢?

这个程序确实在 Windows 上崩溃了,所以我在 Mac 上构建了它来验证它,看看哪里出了问题。到目前为止,这些“块内错误”警告很多,但没有像“写入释放的内存”或任何东西这样可疑的东西。我很困惑。

PS 运行最新的稳定 valgrind v3.7.0,在我运行它的同一台机器上编译和安装。我已经使用 valgrind 很长时间了,以前从未见过这种消息。

4

1 回答 1

1

Valgrind 似乎在抱怨正常的日常行为

确实如此,这似乎是 Mac OSX 版本的 Valgrind 中的一个错误。

您可以尝试创建一个小测试用例并将其报告给 Valgrind 开发人员。

您也可以尝试使用地址消毒剂并查看它报告的内容。

于 2012-04-16T03:02:48.510 回答