macOS 12 Monterey 上的内存检查?

Jon*_*201 8 c++ valgrind memory-leaks llvm clang

Valgrind 现在与 macOS 12 不兼容,我尝试添加编译标志-fsanitize=address,但出现链接错误:

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)
Run Code Online (Sandbox Code Playgroud)

有没有办法让 Valgrind 兼容 macOS 12?

Pau*_*oyd 13

是否有任何通过 macports 或 brew 的补丁可以让您在 macOS 12 上安装 Valgrind?

这都是资源问题。我认为我是唯一使用 macOS 的活跃 Valgrind 开发人员,但我的重点是 FreeBSD。有点遗憾的是,苹果(撰写本文时市值为 2.4 万亿美元)无法付出相对较小的努力来实现这一目标。有几位 IBM 工程师做出了贡献(直接为 s390 和 PPC 以及通过 RedHat 间接做出贡献)。

Valgrind 配置脚本所需的更改相当小。

尝试这个

AC_DEFINE([XCODE_12_0], 110000, [XCODE_VERS value for Xcode 12.0])
Run Code Online (Sandbox Code Playgroud)

在第 555 行之后

12.*)
            AC_DEFINE([XCODE_VERS], XCODE_12_0, [Xcode version])
            ;;
Run Code Online (Sandbox Code Playgroud)
  • 复制内核版本 21.0 的 case 块(第 526 行),类似于
       # 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}"
                  ;;
Run Code Online (Sandbox Code Playgroud)
  • (暂时忽略抑制版本)
  • 跑步./autogen.sh
  • 跑步./configure
  • 跑步make
  • 如果所有工作都运行的话./vg-in-place yes

对 DARWIN_12 进行上述操作再加上一些更改,我得到

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.
Run Code Online (Sandbox Code Playgroud)