Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 381
houbysoft Avatar asked Jan 01 '13 19:01

houbysoft


2 Answers

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.
like image 143
Dogbert Avatar answered Nov 07 '22 08:11

Dogbert


I had this problem using valgrind with macports. It turns out I needed to install with

sudo port install valgrind +universal

I was trying to valgrind a 32bit executable and I believe that without +universal, 32bit support was not being compiled in.

like image 34
robbie_c Avatar answered Nov 07 '22 08:11

robbie_c