Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent Valgrind from starting embedded gdbservers for every new thread?

I'm running valgrind memcheck on a program that spawns thousands of other threads.

The other threads do not generate errors, and I don't care what happens to them.

However, Valgrind insists on opening a named pipe in /tmp every time a new thread spawns. Not only is this wasteful, it actually breaks valgrind. Sometimes valgrind doesn't clean up after itself, and then future children with the same pid (active at a later time) fail to spawn because valgrind can't make a pipe with the right name (it already exists).

How can I prevent Valgrind from making all these pipes!?!

EDIT: Flags I have already tried:

--child-silent-after-fork=yes

and things I have already ruled out:

--track-children=no (default value is no).

like image 431
John Doucette Avatar asked Oct 18 '12 17:10

John Doucette


People also ask

Does Valgrind work with threads?

Overview. DRD is a Valgrind tool for detecting errors in multithreaded C and C++ programs. The tool works for any program that uses the POSIX threading primitives or that uses threading concepts built on top of the POSIX threading primitives.

Is Valgrind single threaded?

Valgrind doesn't schedule the threads itself. It merely ensures that only one thread runs at once, using a simple locking scheme.

What is the difference between Valgrind and GDB?

The GNU Debugger (GDB) allows you to pause a running program and inspect its state. Valgrind's memcheck monitors a program's memory accesses and prints warnings if the program accesses invalid locations or attempts to read values that the program never set (initialized).

Does Valgrind require debug build?

Preparation. To be most effective valgrind requires that debugging information be present in the binaries that are being instrumented, although a full debug build is not required.


1 Answers

Sorry to answer my own question. Just for documentation purposes.

Running with the flag:

--vgdb=no

This is not properly documented in the man pages, since it doesn't tell you that it's going to spew pipes everywhere without the flag, but that's why it does it.

like image 124
John Doucette Avatar answered Oct 26 '22 22:10

John Doucette