Skip to content

[Darwin][Test][leaks] Disable leak detection for asan tests on non-Intel Darwin devices #131676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

thetruestblue
Copy link
Contributor

@thetruestblue thetruestblue commented Mar 17, 2025

detect_leaks option for asan does not work well on Apple Silicon (arm64) MacOS devices and results in hundreds of ASan test failures when run with this option set for all tests.

We should not add this option for tests unless we are targeting an x86_64 device for Darwin, where this seems to be tested and working well.

rdar://147069153

@llvmbot
Copy link
Member

llvmbot commented Mar 17, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (thetruestblue)

Changes

detect_leaks option for asan does not work well on Apple Silicon (arm64) MacOS devices.

We should not add this option for tests unless we are targeting an x86_64 device for Darwin, where this seems to be tested and working well.

rdar://147069153


Full diff: https://github.com/llvm/llvm-project/pull/131676.diff

1 Files Affected:

  • (modified) compiler-rt/test/asan/lit.cfg.py (+7-3)
diff --git a/compiler-rt/test/asan/lit.cfg.py b/compiler-rt/test/asan/lit.cfg.py
index 2da511103da7c..ceb362a5d0555 100644
--- a/compiler-rt/test/asan/lit.cfg.py
+++ b/compiler-rt/test/asan/lit.cfg.py
@@ -25,8 +25,10 @@ def get_required_attr(config, attr_name):
 default_asan_opts = list(config.default_sanitizer_opts)
 
 # On Darwin, leak checking is not enabled by default. Enable on macOS
-# tests to prevent regressions
-if config.host_os == "Darwin" and config.apple_platform == "osx":
+# tests to prevent regressions.
+# Currently, detect_leaks for asan tests only work on Intel MacOS.
+if (config.host_os == "Darwin" and config.apple_platform == "osx"
+    and config.target_arch == "x86_64"):
     default_asan_opts += ["detect_leaks=1"]
 
 default_asan_opts_str = ":".join(default_asan_opts)
@@ -273,7 +275,9 @@ def build_invocation(compile_flags, with_lto=False):
     and (not config.android)
     and (config.target_arch in ["x86_64", "i386", "riscv64", "loongarch64"])
 )
-leak_detection_mac = (config.host_os == "Darwin") and (config.apple_platform == "osx")
+leak_detection_mac = (config.host_os == "Darwin") and (config.apple_platform == "osx") and (
+    config.target_arch == "x86_64"
+)
 leak_detection_netbsd = (config.host_os == "NetBSD") and (
     config.target_arch in ["x86_64", "i386"]
 )

Copy link

github-actions bot commented Mar 17, 2025

✅ With the latest revision this PR passed the Python code formatter.

@thetruestblue
Copy link
Contributor Author

@vitalybuka I filed an issue: #131678

Are you the main owner of Leak Sanitizer or is there anyone else we could reach out to, to let them know? Thanks!

…tel darwin devices

It seems the asan detect_leaks option does not work well on Apple Silicon (arm64) MacOS devices.

We should not add this option unless we are targeting an x86_64 device, where this seems to be tested and working well.

rdar://147069153
@thetruestblue thetruestblue requested a review from MaskRay March 17, 2025 22:01
Copy link
Contributor

@wrotki wrotki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, that's the change I had to do manually every time I wanted to run tests on my Apple Silicon machine, to avoid lsan tests failures muddying the water.

@thetruestblue thetruestblue merged commit 7d4332a into llvm:main Mar 18, 2025
10 checks passed
@thetruestblue thetruestblue deleted the disable-darwin-leaks branch April 29, 2025 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants