Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
638 views
in Technique[技术] by (71.8m points)

c - Can I make valgrind ignore glibc libraries?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

 valgrind --gen-suppressions=all --log-file=valgrind.out ./a.out

Now the output file valgrind.out will contain some automatically-generated suppression blocks like the following:

{
   stupid sendmsg bug: http://sourceware.org/bugzilla/show_bug.cgi?id=14687
   Memcheck:Param
   sendmsg(mmsg[0].msg_hdr)
   fun:sendmmsg
   obj:/usr/lib/libresolv-2.17.so
   fun:__libc_res_nquery
   obj:/usr/lib/libresolv-2.17.so
   fun:__libc_res_nsearch
   fun:_nss_dns_gethostbyname4_r
   fun:gaih_inet
   fun:getaddrinfo
   fun:get_socket_fd
   fun:main
}

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 tell valgrind about that file on the next run:

valgrind --log-file=valgrind --suppressions=sendmsg.supp ./a.out

And valgrind will graciously ignore that stupid upstream bug.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...