我可以让 valgrind 忽略 glibc 库吗?
是否可以告诉 valgrind 忽略某些库集? 特别是 glibc 库..
实际问题: 我有一些代码在正常执行中运行良好。没有泄漏等。
当我尝试通过 valgrind 运行它时,我得到核心转储和程序重新启动/停止。
Core 通常指向 glibc 函数(通常是 fseek、mutex 等)。 我了解 glibc / valgrind 版本不兼容可能存在一些问题。
我尝试了各种 valgrind 版本和 glibc 版本,但没有成功。 有什么建议吗?
Is it possible to tell valgrind to ignore some set of libraries?
Specifically glibc libraries..
Actual Problem:
I have some code that runs fine in normal execution. No leaks etc.
When I try to run it through valgrind, I get core dumps and program restarts/stops.
Core usually points to glibc functions (usually fseek, mutex etc).
I understand that there might be some issue with incompatible glibc / valgrind version.
I tried various valgrind releases and glibc versions but no luck.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能不会回答您的问题,但会为您提供如何抑制某些错误的具体信息(其他人已经提到但没有详细描述):
首先,运行 valgrind 如下:
现在输出文件 valgrind.out 将包含一些自动生成的抑制块,如下所示:
其中“stupid sendmsg bug”和链接是我添加的用于引用此块的名称。现在,将该块保存到
sendmsg.supp
并在下次运行时告诉valgrind
该文件:并且
valgrind
将慷慨地忽略那个愚蠢的上游错误。This probably doesn't answer your question, but will provide you the specifics of how to suppress certain errors (which others have alluded to but have not described in detail):
First, run
valgrind
as follows:Now the output file
valgrind.out
will contain some automatically-generated suppression blocks like the following:Where "stupid sendmsg bug" and the link are the name that I added to refer to this block. Now, save that block to
sendmsg.supp
and tellvalgrind
about that file on the next run:And
valgrind
will graciously ignore that stupid upstream bug.正如 unwind 所指出的,valgrind 有一个复杂的机制来控制对哪些过程进行检测以及如何进行检测。但 valgrind 和 glibc 都是复杂的野兽,你真的、真的、真的不想这样做。获得相互兼容的 glibc 和 valgrind 的简单方法是从您选择的 Linux 发行版中获取两者。事情应该“顺利进行”,如果不顺利,你可以向某人抱怨。
As noted by unwind, valgrind has an elaborate mechanism for controlling which procedures are instrumented and how. But both valgrind and glibc are complicated beasts, and you really, really, really don't want to do this. The easy way to get a glibc and valgrind that are mutually compatible is to get both from the Linux distro of your choice. Things should "just work", and if they don't, you have somebody to complain to.
是的,请查看 Valgrind 的抑制系统。
Yes, look into Valgrind's suppression system.
您可能想在 Valgrind 用户的邮件列表(这是非常有帮助)。您可以抑制某些调用的输出,但是,您所做的只是抑制噪音。电话仍在通过 Valgrind 进行。
为了完成您的需要,您(理想情况下)将 Valgrind 与 glibc 适当匹配或使用
valgrind/valgrind.h
中的宏来解决它们。是的,使用这些,你可以告诉 valgrind 不要碰某些东西。我不确定哪些调用会破坏一切,但是如果您自己的程序在 valgrind 下运行,您也可以(有选择地)不运行自己的程序中的代码。请参阅valgrind/valgrind.h
中的RUNNING_ON_VALGRIND
宏。我想到的另一件事是确保 Valgrind 正确编译为 处理线程。请记住,Valgrind 下的原子操作可能会导致您的程序在竞争操作期间崩溃,而如果配置不正确,则可能不会崩溃。
如果您一直在交换 valgrind 和 glibc 的版本,则您有可能找到匹配项,但在构建时错误地配置了 valgrind。
You probably want to ask about this on the Valgrind user's mailing list (which is extremely helpful). You can suppress output from certain calls, however, suppressing the noise is all you are doing. The calls are still going through Valgrind.
To accomplish what you need, you (ideally) match Valgrind appropriately with glibc or use the macros in
valgrind/valgrind.h
to work around them. Using those, yes, you can tell valgrind not to touch certain things. I'm not sure what calls are borking everything, however you can also (selectively) not run bits of code in your own program if its run under valgrind. See theRUNNING_ON_VALGRIND
macro invalgrind/valgrind.h
.The other thing that comes to mind is to make sure that Valgrind was compiled correctly to deal with threads. Keep in mind that atomic operations under Valgrind could cause your program to crash during racey operations, where it otherwise might not, if not properly configured.
If you have been swapping versions of valgrind and glibc, there's a chance you found a match, but incorrectly configured valgrind at build time.