Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
636 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...