为什么 Valgrind 在有效块内报告读/写错误? [英] Why is Valgrind reporting read/write errors INSIDE valid blocks?

查看:24
本文介绍了为什么 Valgrind 在有效块内报告读/写错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以给出这个输出:

==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 会抱怨?

It seems that Valgrind is complaining about normal everyday behaviour. The blocks in question are still allocated, and the access is inside the memory blocks start and end. So why does valgrind complain?

这个程序在 Windows 上确实会崩溃,所以我在 Mac 上构建了它来 valgrind 它并查看哪里出了问题.到目前为止,有很多这些块内错误"警告,但没有什么像写入已释放的内存"或任何其他东西一样可疑.我很困惑.

This program does crash on windows, so I built it on Mac to valgrind it and see where things are going wrong. So far lots of these "error inside block" warnings but nothing dubious like "write to free'd memory" or anything. I'm quite confused.

PS 运行最新的稳定 valgrind v3.7.0,在我运行它的同一台机器上编译和安装.我用valgrind很久了,以前从来没见过这种消息.

PS running latest stable valgrind v3.7.0, compiled and install on the same machine as I'm running it. I have been using valgrind for a long time, and never seen this sort of message before.

推荐答案

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

It seems that Valgrind is complaining about normal everyday behaviour

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

Indeed it does, and that appears to be a bug in Mac OSX version of Valgrind.

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

You can try to create a small test case and report it to Valgrind developers.

您也可以尝试使用 address sanitizer 并查看它报告的内容.

You could also try address sanitizer and see what it reports.

这篇关于为什么 Valgrind 在有效块内报告读/写错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆