46

I following this guide:

valgrind installation guide

After I have downloading the package, and I have run the sh script, but when I launch the make install command, it couldn't create the folder because it don't have the permission (even though I have used the sudo command).

Furthermore I tried with brew but I have this error:

valgrind: This formula either does not compile or function as expected on macOS versions newer than El Capitan due to an upstream incompatibility.

Error: An unsatisfied requirement failed this build.

th3g3ntl3man
  • 1,926
  • 5
  • 29
  • 50
  • 2
    For those following: as of June 14th, 2017, Valgrind started providing preliminary support for macOS 10.12. See http://valgrind.org/docs/manual/dist.news.html – Ian Taylor Jul 21 '17 at 14:14
  • valgrind worked for me with latest release `valgrind-3.15.0.GIT` using @voltento 's suggestions – A. K. Oct 30 '18 at 05:24

5 Answers5

57

You can download Valgrind's latest version from their website. Then, you can just ./autogen.sh to install Valgrind. I personally did not encounter anything needed to make.

However, the sad news is, even the most recent version of Valgrind is not very usable on Mac OS Sierra. The reason is that Apple has not released the part of the source code that makes Valgrind crash, without which, the Valgrind maintainers can hardly do anything. You can read more about the discussion around the issue here .

Because Mac OS kernel is under Apple Public Source License, it has to be open-sourced someday. Thus, a Sierra-complitable version of Valgrind is only a matter of time.

Currently, I use Valgrind under Linux. This is all I can suggest now.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Musen
  • 1,244
  • 11
  • 23
  • Apple recently [released](https://opensource.apple.com/release/os-x-1012.html) the source of [XNU](https://opensource.apple.com/source/xnu/xnu-3789.1.32/) for the 10.12 OS. I'm sure the Valgrind team is working on that. – Cong Ma Nov 27 '16 at 08:59
  • 4
    As of 2017-01-03, the latest Valgrind source checked out of Subversion — their choice of VCS, version control system — at 'checked out revision 16192' still runs into the `valgrind: mmap-FIXED(0x0, 253952) failed in UME (load_segment1) with error 12 (Cannot allocate memory).` error that is described in the discussion. 'Tis irksome that there's still a problem when the source was, apparently, released at the end of November 2016. I've no further information to offer. – Jonathan Leffler Jan 04 '17 at 01:00
  • Can confirm. Still unfixed in rev 16266. – Michael Böckling Mar 11 '17 at 23:10
  • It seems as of today, a Sierra-compatible Valgrind is not released yet? The latest update was Oct 20, 2016. – Violapterin Mar 30 '17 at 12:10
  • 1
    The latest release worked for me. Following Jonathen Leffler's comment, I checked out the latest Valgrind source ('Checked out revision 16393') and followed the instructions on the [valgrind download repository page](http://valgrind.org/downloads/repository.html). I was previously getting the same error with the 20 October 2016 release (valgrind-3.12.0). – PZwan May 17 '17 at 13:17
  • I get a new error now... ``valgrind: m_libcfile.c:70 (Int vgPlain_safe_fd(Int)): Assertion 'newfd >= VG_(fd_hard_limit)' failed.`` which is due to ``fcntl`` failing. Progress I guess? @PZwan got me all excited! – Ethan Coon May 18 '17 at 01:36
  • Similar question on [apple.stackexchange](https://apple.stackexchange.com/q/285329/216401) and similar resolution: install VirtualBox, run valgrind on Linux :\ – MmmHmm Jun 11 '17 at 13:30
  • Valgrind 3.13.0 seems to be working to some extent for me on macOS 10.12.6. – chrisdembia Aug 03 '17 at 22:22
  • Did anyone get Valgrind to actually work on 10.12.6, 3.13.0 wont compile for me it errors out. – Marshall Asch Sep 23 '17 at 19:10
  • It(3.13)does work in macOS 10.12.6. Try `brew install automake` before `./autogen.sh` Check out http://valgrind.org/downloads/repository.html – Joe Bobson Dec 29 '17 at 15:25
  • Not compatible with Mojave. – Pedro Paulo Amorim Sep 17 '19 at 21:59
12

Latest Valgrind (git version 3.13.0) now works on MacOS Sierra but needs Xcode command line tools installed (installs needed headers).

Run this before building Valgrind:

xcode-select --install

Thanks goes to this post.

guru_florida
  • 636
  • 5
  • 13
  • 2
    Also note that the latest Xcode contains clang 9 which requires a change in the configure script - when downloaded it only goes to 8. – koenig Dec 21 '17 at 20:16
  • 1
    `xcode-select: error: command line tools are already installed, use "Software Update" to install updates` and homebrew `valgrind: This formula either does not compile or function as expected on macOS versions newer than Sierra due to an upstream incompatibility.` (high sierra) – rogerdpack Mar 27 '18 at 22:02
  • @rogerdpack you have to download it and build it yourself, homebrew can't install it yet – jirig Apr 14 '18 at 13:31
  • 1
    OK looks like high sierra is actually "a different question" https://stackoverflow.com/questions/48714807/unable-to-build-and-install-valgrind-on-macos-high-sierra sorry for the noise – rogerdpack Jul 31 '18 at 23:00
5

If you get an error similar to

valgrind: This formula either does not compile or function as expected on macOS versions newer than Sierra due to an upstream incompatibility.

you can try the workaround brew install --HEAD valgrind I found this information here https://www.gungorbudak.com/blog/2018/04/28/how-to-install-valgrind-on-macos-high-sierra/

voltento
  • 833
  • 10
  • 26
3

If you happen to be on Sierra still, this works (but not on High Sierra), just do

$ brew install valgrind

 valgrind: This formula either does not compile or function as expected on macOS
 versions newer than Sierra due to an upstream incompatibility.
 Error: An unsatisfied requirement failed this build.

Update: seems it works on "High Sierra" OOTB now too, it now says:

...versions newer than High Sierra due to an upstream incompatibility...

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
3

The easy alternative to valgrind on mac is called 'leaks'. It is a command-line tool, so if you don't already have xcode command-line tools installed, do so with 'xcode-select --install'.

Then, to test for leaks, just compile your prog then run 'leaks -atExit -- ./your_prog'

larboyer
  • 119
  • 1
  • 3