Reputation: 463
Valgrind is not compatible with macOS 12 now, and I tried to add compile flag -fsanitize=address
, but got link error:
Undefined symbols for architecture x86_64:
"___asan_init", referenced from:
_asan.module_ctor in main.cpp.o
"___asan_version_mismatch_check_apple_clang_1300", referenced from:
_asan.module_ctor in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there any way to make Valgrind compatible with macOS 12?
Upvotes: 8
Views: 7474
Reputation: 41
I don't have enough reputation to comment on Paul's post. After I made the changes he stated, I got the following error. I am currently on Monterey 12.1 Beta (21C5021h) with Intel i7.
./vg-in-place yes
==30798== Memcheck, a memory error detector
==30798== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==30798== Using Valgrind-3.18.0.GIT-lbmacos and LibVEX; rerun with -h for copyright info
==30798== Command: yes
==30798==
==30798== Invalid read of size 8
==30798== at 0x100017126: cerror_nocancel (in /usr/lib/dyld)
==30798== by 0x1000156E8: kdebug_is_enabled (in /usr/lib/dyld)
==30798== by 0x10004215B: dyld3::kdebug_trace_dyld_marker(unsigned int, dyld3::kt_arg, dyld3::kt_arg, dyld3::kt_arg, dyld3::kt_arg) (in /usr/lib/dyld)
==30798== by 0x100019375: (below main) (in /usr/lib/dyld)
==30798== Address 0x8 is not stack'd, malloc'd or (recently) free'd
==30798==
==30798==
==30798== Process terminating with default action of signal 11 (SIGSEGV)
==30798== Access not within mapped region at address 0x8
==30798== at 0x100017126: cerror_nocancel (in /usr/lib/dyld)
==30798== by 0x1000156E8: kdebug_is_enabled (in /usr/lib/dyld)
==30798== by 0x10004215B: dyld3::kdebug_trace_dyld_marker(unsigned int, dyld3::kt_arg, dyld3::kt_arg, dyld3::kt_arg, dyld3::kt_arg) (in /usr/lib/dyld)
==30798== by 0x100019375: (below main) (in /usr/lib/dyld)
==30798== If you believe this happened as a result of a stack
==30798== overflow in your program's main thread (unlikely but
==30798== possible), you can try to increase the size of the
==30798== main thread stack using the --main-stacksize= flag.
==30798== The main thread stack size used in this run was 8388608.
==30798==
==30798== HEAP SUMMARY:
==30798== in use at exit: 0 bytes in 0 blocks
==30798== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==30798==
==30798== All heap blocks were freed -- no leaks are possible
==30798==
==30798== For lists of detected and suppressed errors, rerun with: -s
==30798== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
./vg-in-place: line 31: 30798 Segmentation fault: 11 VALGRIND_LIB="$vgbasedir/.in_place" VALGRIND_LIB_INNER="$vgbasedir/.in_place" "$vgbasedir/coregrind/valgrind" "$@"
Upvotes: 2
Reputation: 6946
Are there any patches via macports or brew that allow you to install Valgrind on macOS 12?
It's all a question of resources. I think that I'm the only active Valgrind dev that uses macOS, but my focus is on FreeBSD. It's a bit of a pity that Apple (market cap of $2.4 trillion at the time of writing) can't commit some relatively small amount of effort to achieve this. There are several IBM engineers contributing (directly for s390 and PPC and indirectly via RedHat).
The changes required to the Valgrind configure scripts are fairly minor.
Try this
AC_DEFINE([XCODE_12_0], 110000, [XCODE_VERS value for Xcode 12.0])
and after line 555
12.*)
AC_DEFINE([XCODE_VERS], XCODE_12_0, [Xcode version])
;;
# comes after the 20.0) case
21.*)
AC_MSG_RESULT([Darwin 21.x (${kernel}) / macOS 12 Monterey])
AC_DEFINE([DARWIN_VERS], DARWIN_12_00, [Darwin / Mac OS X version])
DEFAULT_SUPP="darwin20.supp ${DEFAULT_SUPP}"
DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
;;
./autogen.sh
./configure
make
./vg-in-place yes
Doing the above plus a few more changes for DARWIN_12, I get
paulf> ./vg-in-place yes
==12358== Memcheck, a memory error detector
==12358== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12358== Using Valgrind-3.18.0.GIT-lbmacos and LibVEX; rerun with -h for copyright info
==12358== Command: yes
==12358==
valgrind: m_mach/dyld_cache.c:244 (int try_to_init(void)): Assertion 'dyld_cache.header->mappingCount == 3' failed.
Upvotes: 13