Skip to content

[asan][test] Attempt to fix suppressions-alloc-dealloc-mismatch.cpp on Darwin #124987

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

Conversation

benlangmuir
Copy link
Collaborator

Add %env_asan_opts=alloc_dealloc_mismatch=1 since it is disabled by default.

rdar://143830493

…n Darwin

Add %env_asan_opts=alloc_dealloc_mismatch=1 since it is disabled by
default.

rdar://143830493
@llvmbot
Copy link
Member

llvmbot commented Jan 29, 2025

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

Author: Ben Langmuir (benlangmuir)

Changes

Add %env_asan_opts=alloc_dealloc_mismatch=1 since it is disabled by default.

rdar://143830493


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

1 Files Affected:

  • (modified) compiler-rt/test/asan/TestCases/suppressions-alloc-dealloc-mismatch.cpp (+3-3)
diff --git a/compiler-rt/test/asan/TestCases/suppressions-alloc-dealloc-mismatch.cpp b/compiler-rt/test/asan/TestCases/suppressions-alloc-dealloc-mismatch.cpp
index fe88a5d0c9bf15a..df6df6aa9547111 100644
--- a/compiler-rt/test/asan/TestCases/suppressions-alloc-dealloc-mismatch.cpp
+++ b/compiler-rt/test/asan/TestCases/suppressions-alloc-dealloc-mismatch.cpp
@@ -1,10 +1,10 @@
 // Check that without suppressions, we catch the issue.
 // RUN: %clangxx_asan -O0 %s -o %t
-// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
+// RUN: %env_asan_opts=alloc_dealloc_mismatch=1 not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
 
 // RUN: echo "alloc_dealloc_mismatch:function" > %t.supp
-// RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
-// RUN: %clangxx_asan -O3 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
+// RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=alloc_dealloc_mismatch=1:suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
+// RUN: %clangxx_asan -O3 %s -o %t && %env_asan_opts=alloc_dealloc_mismatch=1:suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
 
 #include <stdio.h>
 #include <stdlib.h>

@benlangmuir benlangmuir merged commit f0d05b0 into llvm:main Jan 30, 2025
11 checks passed
@benlangmuir benlangmuir deleted the asan-suppressions-alloc-dealloc-mismatch-darwin branch January 30, 2025 00:07
@vitalybuka
Copy link
Collaborator

Thanks,
It was also broken on android, let see if it helps https://lab.llvm.org/buildbot/#/builders/186/builds/6091

@vitalybuka
Copy link
Collaborator

@vitalybuka
Copy link
Collaborator

Exactly as defined:

ASAN_FLAG(bool, alloc_dealloc_mismatch,
          !SANITIZER_APPLE && !SANITIZER_WINDOWS && !SANITIZER_ANDROID,
          "Report errors on malloc/delete, new/free, new/delete[], etc.")

@benlangmuir
Copy link
Collaborator Author

It looks like this fixed Windows, but not Darwin
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-cmake-RA-expensive/3251/

The new failure looks like the suppression mechanism is failing in the -O3 case

error: CHECK-IGNORE: expected string not found in input
// CHECK-IGNORE: strlen ignored
                 ^
<stdin>:1:1: note: scanning from here
=================================================================
^
<stdin>:2:28: note: possible intended match here
==78843==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x602000000070
                           ^

@benlangmuir
Copy link
Collaborator Author

benlangmuir commented Jan 30, 2025

Ah, I see in compiler-rt/test/asan/TestCases/suppressions-function.cpp:

// FIXME: atos does not work for inlined functions, yet llvm-symbolizer
// does not always work with debug info on Darwin.
// UNSUPPORTED: darwin

So it seems this is a known issue with suppressions in optimized builds. I'll apply the same thing here unless you have a better idea.

Edit: done in 4985804

@dyung
Copy link
Collaborator

dyung commented Feb 3, 2025

Can we get this change cherry-picked to the release branch? We are seeing the Windows ASAN failures on our internal bot that is building the release branch.

@benlangmuir
Copy link
Collaborator Author

/cherry-pick f0d05b0 751ae26 4985804

@llvmbot
Copy link
Member

llvmbot commented Feb 3, 2025

/cherry-pick f0d05b0 751ae26 4985804

Error: Command failed due to missing milestone.

@benlangmuir benlangmuir added this to the LLVM 20.X Release milestone Feb 3, 2025
@benlangmuir
Copy link
Collaborator Author

/cherry-pick f0d05b0 751ae26 4985804

@llvmbot
Copy link
Member

llvmbot commented Feb 3, 2025

/pull-request #125583

zacklj89 added a commit that referenced this pull request Feb 5, 2025
…ilds (#125871)

Including #124987, we have failures on Windows on x86 with `/O2` builds,
similar to Darwin. This disables the test for MSVC-x86.
swift-ci pushed a commit to swiftlang/llvm-project that referenced this pull request Feb 5, 2025
…n Darwin (llvm#124987)

Add %env_asan_opts=alloc_dealloc_mismatch=1 since it is disabled by
default.

rdar://143830493
(cherry picked from commit f0d05b0)
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…ilds (llvm#125871)

Including llvm#124987, we have failures on Windows on x86 with `/O2` builds,
similar to Darwin. This disables the test for MSVC-x86.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants