Valgrind Mojave

Question or issue on macOS:

Valgrind for macOS. This repository contains a version of Valgrind including a few patches to improve support for the macOS platform. Valgrind now builds on macOS Mojave (tested on 10.14.6) & Catalina (tested 10.15.1 & 10.15.4). Apr 08, 2020 Valgrind 3.16.0 for MacOS Mojave 10.14.6 8th April 2020 8th April 2020 / By Roland Ihasz / C, Software Development, Static Code Analyzers / mac, OSX, Qt, Valgrind After many unstable versions and unsuccessful tries found a working but still experimental solution for MacOS Mojave 1.14.6 using homebrew.

I tried to install Valgrind with brew install Valgrind and got :

I tried brew install –HEAD Valgrind.

Instead, after successfully installing the dependencies autoconf, automake and libtool, when it tries to install valgrind, I get a configure error:

My OS is macOS Mojave(10.14), so does it mean that I can’t install a functioning Valgrind with Homebrew presently?

Mojave

How to solve this problem?

Solution no. 1:

A (rather painful) install from source workaround based on this patch, this post and this answer.

Cached

If you get the following error: No rule to make target '/usr/include/mach/mach_vm.defs’, you will need to run xcode-select --install. You might need to install Xcode from the app store if you don’t already have it. Once that’s done, you will need to edit the coregrind/Makefile:

Search for:

After double checking the below folder exists, prefix every line with:

End result should be:

Now run make again and the includes should be found. But that doesn’t necessarily mean it will compile. I got the following error:

A fix for this is to add the following line:

to the following files:

  • coregrind/m_syscall.c
  • coregrind/m_syswrap/syswrap-darwin.c
  • coregrind/vg_preloaded.c

Finally, you need to cross your fingers hoping no other errors show up:

Valgrind Mojave

Solution no. 2:

You may use Experimental Version of Valgrind for macOS 10.14.5 Mojave at:

The command to use it is:

It is still experimental and needs some work but for simple projects works already… Enjoy!

Solution no. 3:

addition: I found this one worked for me on my OSX 10.14

A branch that is working to get OSX correct. something to tide us over until we get a real valgrind version fixed.

Solution no. 4:

I am having the same issue. It seems like valgrind is not compatible with the newest macOS(10.14 Mojave). Tried installing it the High Sierra way (https://www.gungorbudak.com/blog/2018/04/28/how-to-install-valgrind-on-macos-high-sierra/) and got the same output you described. The only solution I can offer you right now is either working on virtual machine (https://www.virtualbox.org/) or using Docker (https://www.gungorbudak.com/blog/2018/06/13/memory-leak-testing-with-valgrind-on-macos-using-docker-containers/).

Solution no. 5:

I have just found a working solution to use VALGRIND on my Mac (Mojave 10.14.6). Just run this command :

(From https://github.com/LouisBrunner/valgrind-macos)

Hope it will work for you.

Solution no. 6:

Not a proper solution for macOs, but for the time being, I created a docker image. After installing docker for macOS, this is how to start valgrind:

How to install Valgrind on macOS Mojave? - Answers

Solution no. 7:

As of 2019-NOV-30, it is possible to build against OS X 10.14.6 via https://github.com/sowson/valgrind and https://github.com/LouisBrunner/valgrind-macos

However, there are many test failures (see the LouisBrunner link), noise during runs, and SEGVs when running against non-trivial programs: installing is, well, installing. YMMV.

Solution no. 8:

You can follow alex.m’s answer to get valgrind, but if you’r using it on a int main() { return 0; } program, you’ll get many weird errors, and non-existing allocs / free.

To ‘hide’ these annoying errors, you can follow theses steps (it’s more a workaround than a real fix) (based on this wiki page and some research in Valgrind’s source code):

  • First, create and compile a int main() { return 0; } program.
  • Execute the following command (to create file containing error suppression):

Valgrind Alternative Mac Mojave

Valgrind Mojave

valgrind --leak-check=full --show-reachable=yes --error-limit=no --gen-supressions=all --log-file=$YOUR_LOG$ $YOUR_BINARY$

  • Using this gawk script, create the .supp valgrind file:

cat ./$YOUR_LOG$ | ./$YOUR_SCRIPT_FILE$ > minimal.supp

See All Results For This Question

  • Copy and Past minimal.supp content at the end of $YOUR_VALGRIND_INSTALLATION_PATH$/lib/valgrind/default.supp file

And you are done! Weird and nonexistent errors will be ignored.
If you also want’s to remove the non-existing allocs, frees etc, you can directly edit Valgrind’s source code. Or just use heapusage for leak-tracking

Solution no. 9:

(works on mojave 10.14.6)

Solution no. 10:

As others have mentioned, Louis Brunner maintains a working version at https://github.com/LouisBrunner/valgrind-macos.

Valgrind Mac Os Mojave

This worked for me for MacOS 10.15.7 Catalina.

How To Install Valgrind On MacOS Mojave? - Answers

Hope this helps!