Search code examples
valgrindosx-mountain-lion

valgrind not working on OS X 10.8


Every time I try to run valgrind on my OS X 10.8 notebook, I get:

bad executable (no stack)
valgrind: ./a.out: cannot execute binary file

What is the problem? How can I fix this? Everything works fine on Linux, so it's not that I'm somehow misusing valgrind. The exact line I'm using is valgrind --tool=memcheck --leak-check=full ./a.out.


Solution

  • I was getting the same error, but I just upgraded valgrind to 3.8.1 (brew upgrade valgrind using HomeBrew for me), and it works, although running Valgrind prints the following warning:

    WARNING: Support on MacOS 10.8 is experimental and mostly broken.
    WARNING: Expect incorrect results, assertions and crashes.
    WARNING: In particular, Memcheck on 32-bit programs will fail to
    WARNING: detect any errors associated with heap-allocated data.