valgrind-macos icon indicating copy to clipboard operation
valgrind-macos copied to clipboard

Won't start on Mac OS 26.1 (Library not loaded)

Open nym21 opened this issue 2 months ago • 12 comments

Context

Crashes right after install:

→ valgrind
dyld[53164]: Library not loaded: @rpath/libmydyld.so
  Referenced from: <C0ACADCA-2E83-3D1F-8ED1-CDDEAB161CD4> /opt/homebrew/Cellar/valgrind/HEAD-926705e/libexec/valgrind/memcheck-arm64-darwin
  Reason: tried: '/opt/homebrew/Cellar/valgrind/HEAD-926705e/libexec/valgrind/libmydyld.so' (missing LC_LOAD_DYLIB (must link with at least libSystem.dylib)), '/opt/homebrew/Cellar/valgrind/HEAD-926705e/libexec/coregrind/libmydyld.so' (no such file), '/opt/homebrew/Cellar/valgrind/HEAD-926705e/libexec/valgrind/libmydyld.so' (missing LC_LOAD_DYLIB (must link with at least libSystem.dylib)), '/opt/homebrew/Cellar/valgrind/HEAD-926705e/libexec/coregrind/libmydyld.so' (no such file), '/usr/local/lib/libmydyld.so' (no such file), '/usr/lib/libmydyld.so' (no such file, not in dyld cache)
fish: Job 1, 'valgrind' terminated by signal SIGABRT (Abort)

I checked and the files indeed don't exist

Information

  • macOS architecture (uname -m): arm64
  • macOS version (sw_vers):
  • ProductName: macOS
  • ProductVersion: 26.1
  • BuildVersion: 25B78
  • Xcode version (xcrun --sdk macosx --show-sdk-version): 26.1

nym21 avatar Nov 07 '25 10:11 nym21

Hi @nym21,

Thank you for your report. I think this should be fairly straightforward to fix, unfortunately I do not have access to a macOS 26 computer at the moment (and the GitHub runner seems happy with it).

So this might need to wait a bit longer for me to have a dev machine.

LouisBrunner avatar Nov 07 '25 10:11 LouisBrunner

No worries, good luck !

nym21 avatar Nov 07 '25 10:11 nym21

I finally have macOS 26 to test with but unfortunately I don't have a (great) solution yet.

I can reproduce the same issue by installing through brew but not locally. When looking at the installed files, I could see that libmydyld.so and libmySystem.so don't seem to be built correctly. They have the wrong id name, which you can check with otool -D, /opt/homebrew/opt/valgrind/libexec/valgrind/libSystem.B.dylib instead of /usr/lib/libSystem.B.dylib and /opt/homebrew/opt/valgrind/libexec/valgrind/libdyld.dylib instead of /usr/lib/system/libdyld.dylib. Changing them manually to the correct value doesn't solve the issue, the Valgrind tool just crashes when dyld initializes the binary.

So until I understand why this is happening, if brew changed something on macOS 26, etc, you can build from source instead. Just clone this repo and run ./autogen.sh && ./configure --prefix=where_you_want_to_install && make -j 16 && sudo make install. It's a bit annoying but at least you can use Valgrind for now.

LouisBrunner avatar Nov 12 '25 19:11 LouisBrunner

Thanks for trying !

nym21 avatar Nov 13 '25 08:11 nym21

I do that but It says zsh: command not found: valgrind when I try to use cachegrind.

Nikky112 avatar Nov 14 '25 10:11 Nikky112

@Nikky112 What file path did you add in configure --prefix=path? Is that in your $PATH variable?

If you chose something like configure --prefix=/Users/abc/valgrind you would then need to add /Users/abc/valgrind/bin in your PATH, e.g. export PATH=$PATH:/Users/abc/valgrind/bin.

LouisBrunner avatar Nov 14 '25 10:11 LouisBrunner

I used the same path where Homebrew had already installed it, do I need to change the PATH to add it as well?

Nikky112 avatar Nov 14 '25 11:11 Nikky112

Depends. Where did you install it?

Homebrew will usually install it in something like /opt/homebrew/Cellar/valgrind/HEAD-b1d25c5/ with the binary being at /opt/homebrew/Cellar/valgrind/HEAD-b1d25c5/bin/valgrind. After that brew will link the command in /opt/homebrew/bin, which is usually the path in your PATH.

If you did the above but didn't link it then your shell won't find it. I would suggest you find where it is installed (find /usr /opt -name valgrind) and make sure to include the path in your PATH variable. Or install it in a standard directory which is already in your PATH (but maybe avoid messing with the brew files).

LouisBrunner avatar Nov 14 '25 13:11 LouisBrunner

Ok, now it works, tysm!

Nikky112 avatar Nov 14 '25 16:11 Nikky112

It builds successfully it seems but sadly when I try to run it I get:

→ ./valgrind
valgrind: Unknown/uninstalled VG_PLATFORM 'arm64-darwin'

nym21 avatar Nov 17 '25 14:11 nym21

You can't use valgrind this way. Either you need to install it fully on your system or you need to use the vg-in-place script.

Check this document for reference: https://github.com/LouisBrunner/valgrind-macos/blob/main/README_DEVELOPERS#L10-L25

LouisBrunner avatar Nov 17 '25 18:11 LouisBrunner

Missed that, thank you

nym21 avatar Nov 18 '25 10:11 nym21