Valgrind for Mac OS X. Some assembly required.

Valgrind is a powerful open-source memory debugger. This is a port of Valgrind for Mac OS X.
http://valgrind.org/
http://www.apple.com/macosx/

Caveat programmer

This port is UNSUPPORTED and INCOMPLETE and BUGGY. It may not find bugs in your program, or run your program correctly, or run your program at all.

Requirements

Download

valgrind-opensource-4 (2008-10-27; patch for valgrind r8180, vex r1854)
New in this version:

See the release history for older versions and change logs.

Build

Get and patch Valgrind sources (Valgrind 3.3.1 r8180, VEX r1854).

    svn co -r8180 svn://svn.valgrind.org/valgrind/trunk valgrind
    svn update -r1854 valgrind/VEX
    patch -p1 -d valgrind < /path/to/valgrind-opensource-2.patch
Build and install into /usr/local/bin/valgrind.
    cd valgrind
    ./autogen.sh
    ./configure
    make
    sudo make install

Run

    valgrind [--arch=] [valgrind-options...] /path/to/program [program-options ...]

Some things that don't work

Errors in system libraries

Some system libraries have false positives or legitimate errors. Valgrind has a "suppression file" mechanism to ignore specified errors. This port does not include any suppressions, so you'll have to discover them on your own. Please do not file bug reports against system libraries on Valgrind evidence alone.

Messages you may see while running

If you see messages like the following, then your program is using a system call that Valgrind doesn't support. Your program may run incorrectly after this.

    UNKNOWN syscall
    UNKNOWN mach message descriptor
    UNKNOWN host message
    UNKNOWN task message
    UNKNOWN thread message
    UNKNOWN fcntl
    UNKNOWN ioctl
Messages like the following can probably be ignored.
    UNKNOWN __disable_threadsignal is unsupported
    UNKNOWN sigaction is unsupported
    UNKNOWN Mach port modified
Messages like the following indicate a mismatch between Valgrind's memory map and the kernel. Occasional failures are expected in multithreaded programs. If the failure repeats for the same address range, then there may be a problem causing false errors or crashes.
    sync check at ...: FAILED


seal! Greg Parker
gparker@apple.com
Sealie Software