1

How can I get Valgrind working on my mac? Mac specs: mid-2012 11" 2GHz i7 MacBook Air with macOS Sierra 10.12.5. FWIW, brew install valgrind fails to build, as well as these steps from Zed Shaw's "Learn C The Hard Way" ex4:

# 1) Download it (use wget if you dont have curl)
curl -O http://valgrind.org/downloads/valgrind-3.12.0.tar.bz2

# use md5sum to make sure it matches the one on the site
md5sum valgrind-3.12.0.tar.bz2

# 2) Unpack it.
tar -xjvf valgrind-3.12.0.tar.bz2

# cd into the newly created directory
cd valgrind-3.12.0

# 3) configure it
./configure

# 4) make it
make

# 5) install it (need root)
sudo make install

Valgrind also fails after modifying the file valgrind-3.12.0/coregrind/m_main.c line 4061 from:
#if defined(VGO_darwin) && DARWIN_VERS == DARWIN_10_10
to:
#if defined(VGO_darwin)
(per http://valgrind.10908.n7.nabble.com/Unable-to-compile-on-Mac-OS-X-10-11-td57237.html)
...I was able to complete an installation of Valgrind (prior to changing m_main.c the make error'd out) but unfortunately, now the simple test recommended in the README file for verifying the install is failing:

See if it works. Try "valgrind ls -l". Either this works, or it bombs out with some complaint.

The complaint:

$  valgrind ls -l
valgrind: mmap-FIXED(0x0, 253952) failed in UME (load_segment1) with error 12 (Cannot allocate memory).

I'm not sure what exactly this means, so it would be great if someone could help parse the "complaint" and suggest a means to get a successful install of or alternative to Valgrind on macOS Sierra.

FWIW: per Valgrind's website announcement:

20 October 2016: valgrind-3.12.0 is available. This release supports: X86/Linux, AMD64/Linux, ARM32/Linux, ARM64/Linux, PPC32/Linux, PPC64BE/Linux, PPC64LE/Linux, S390X/Linux, MIPS32/Linux, MIPS64/Linux, ARM/Android, ARM64/Android, MIPS32/Android, X86/Android, X86/Solaris, AMD64/Solaris, X86/MacOSX 10.10 and AMD64/MacOSX 10.10. There is also preliminary support for X86/MacOSX 10.11/12, and AMD64/MacOSX 10.11/12. For more details see the release notes.

...and release notes:

Preliminary support for MacOS 10.12 (Sierra) has been added.


Per this solution: https://stackoverflow.com/a/43431715/5225057 I have also tried the following,

svn checkout -r 16297 svn://svn.valgrind.org/valgrind/trunk
cd trunk
curl https://bugsfiles.kde.org/attachment.cgi?id=105218 > patch.txt
svn patch patch.txt
./autogen.sh
./configure
make
make install

and am left with:

valgrind: mmap-FIXED(0x0, 253952) failed in UME (load_segment1) with error 12 (Cannot allocate memory).


UPDATE per thiagoveloso's answer:

MacPorts Install Success

$  man port
$  port version
Version: 2.4.1
$  sudo port install valgrind
Password:
--->  Computing dependencies for valgrind
--->  Fetching archive for valgrind
--->  Attempting to fetch valgrind-3.12.0_0.darwin_16.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/valgrind
--->  Attempting to fetch valgrind-3.12.0_0.darwin_16.x86_64.tbz2 from http://lil.fr.packages.macports.org/valgrind
--->  Attempting to fetch valgrind-3.12.0_0.darwin_16.x86_64.tbz2 from https://packages.macports.org/valgrind
--->  Fetching distfiles for valgrind
--->  Attempting to fetch valgrind-3.12.0.tar.bz2 from http://ykf.ca.distfiles.macports.org/MacPorts/mpdistfiles/valgrind
--->  Attempting to fetch valgrind-3.12.0.tar.bz2 from https://distfiles.macports.org/valgrind
--->  Verifying checksums for valgrind                                               
--->  Extracting valgrind
--->  Applying patches to valgrind
--->  Configuring valgrind
--->  Building valgrind
--->  Staging valgrind into destroot
--->  Installing valgrind @3.12.0_0
--->  Activating valgrind @3.12.0_0
--->  Cleaning valgrind
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.
$  valgrind --version
valgrind-3.12.0
$  valgrind ls -l
valgrind: mmap-FIXED(0x0, 253952) failed in UME (load_segment1) with error 12 (Cannot allocate memory).

UPDATE:
per http://valgrind.org/docs/manual/dist.news.html valgrind 3.13.0 has improved support for macOS 10.12... hopefully this will be a workable solution.

1

Are you stuck to Homebrew? Otherwise you can install Macports and just type:

$ sudo port install valgrind

"Preliminary" support for macOS 10.12 has been added in version 3.12.0: Valgrind.org

  • Thanks for the suggestion, have never used Macports. Do u have a working Macports install of valgrind on Sierra? – Mr. Kennedy Jun 7 '17 at 18:33
  • Yes I do. It installs and works just fine on my 2012 13" Macbook Pro under Sierra 10.12.5. – thiagoveloso Jun 7 '17 at 18:42
  • swEEt - thanks! Will give it a go when I am back in front of my lappy :) – Mr. Kennedy Jun 7 '17 at 21:03
  • Please see my edit, the installation was successful but valgrind is non-functional. – Mr. Kennedy Jun 8 '17 at 1:04
  • Yeah, I can reproduce your issue. Apparently I was very luck to use Valgrind on Sierra to debug a GIMP error, because it seems to be on the the very few applications that are currently supported -- see this comment by Valgrind's author Louis Brunner: bugs.kde.org/show_bug.cgi?id=365327#c12. So I guess you'll have either to wait a little bit more until Valgrind works ok for Sierra or find an alternative - perhaps Instruments? – thiagoveloso Jun 8 '17 at 4:01
0

With the June 15, 2017 release of valgrind 3.13.0, I am able to install and make use of valgrind on macOS Sierra (10.12.5). As a base case, I can successfully evaluate a very basic valgrind ls -l. I will be continuing to evaluate this build of valgrind as I complete the exercises in ZS's LCTHW.

Of note, I installed with Homebrew and have not (yet) tested installation with MacPorts or per a curl download, md5 checksum, tar unpacking, ./configure, make and make install.

per http://valgrind.org/docs/manual/dist.news.html:

Release 3.13.0 (15 June 2017) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3.13.0 is a feature release with many improvements and the usual collection of bug fixes.

This release supports X86/Linux, AMD64/Linux, ARM32/Linux, ARM64/Linux, PPC32/Linux, PPC64BE/Linux, PPC64LE/Linux, S390X/Linux, MIPS32/Linux, MIPS64/Linux, ARM/Android, ARM64/Android, MIPS32/Android, X86/Android, X86/Solaris, AMD64/Solaris and AMD64/MacOSX 10.12.


UPDATE Valgrind is unsupported thus far on macOS High Sierra (up through 10.13.3)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .