views:

269

answers:

3

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?

+2  A: 

Yes, look into Valgrind's suppression system.

unwind
I think he wants to tell valgrind not to profile certain glibc functions, not just suppress the resulting output.
Tim Post
@Tim: Exactly! Basically I want valgrind to ignore them (execute them just like normal execution)
Jack
@Jack - you'll need to get rather familiar with valgrind internals for that. I really suggest taking a peek at valgrind/valgrind.h , its hard to suggest something unless you post the output you received from valgrind.
Tim Post
+1  A: 

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 the RUNNING_ON_VALGRIND macro in valgrind/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.

Tim Post
+1  A: 

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.

Norman Ramsey