Skip to content

[LSan] skip leaks from dlerror #142876

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 4 commits into from
Jun 5, 2025

Conversation

fmayer
Copy link
Contributor

@fmayer fmayer commented Jun 4, 2025

We have known false positives, and the return value is never
user-managed anyway.

fmayer added 2 commits June 4, 2025 16:42
Created using spr 1.3.4
@fmayer fmayer requested a review from thurstond June 4, 2025 23:43
@fmayer fmayer marked this pull request as ready for review June 4, 2025 23:43
@llvmbot llvmbot added compiler-rt compiler-rt:hwasan Hardware-assisted address sanitizer compiler-rt:lsan Leak sanitizer compiler-rt:sanitizer labels Jun 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 4, 2025

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

Author: Florian Mayer (fmayer)

Changes

We have known false positives, and the return value is never
user-managed anyway.


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

2 Files Affected:

  • (modified) compiler-rt/lib/lsan/lsan_common.cpp (+2-1)
  • (modified) compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp (+2-2)
diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp
index 7ab9e4ff2ac9f..b17a17e1193bc 100644
--- a/compiler-rt/lib/lsan/lsan_common.cpp
+++ b/compiler-rt/lib/lsan/lsan_common.cpp
@@ -124,7 +124,8 @@ static const char kStdSuppressions[] =
 #  endif
     // TLS leak in some glibc versions, described in
     // https://sourceware.org/bugzilla/show_bug.cgi?id=12650.
-    "leak:*tls_get_addr*\n";
+    "leak:*tls_get_addr*\n"
+    "leak:*dlerror*\n";
 
 void InitializeSuppressions() {
   CHECK_EQ(nullptr, suppression_ctx);
diff --git a/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp b/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp
index 15455ba5af780..b6e486b291f3a 100644
--- a/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp
+++ b/compiler-rt/test/hwasan/TestCases/Posix/dlerror.cpp
@@ -2,7 +2,6 @@
 // This is currently not implemented, so this test is XFAIL.
 
 // RUN: %clangxx_hwasan -O0 %s -o %t && HWASAN_OPTIONS=detect_leaks=1 %run %t
-// XFAIL: *
 
 #include <assert.h>
 #include <dlfcn.h>
@@ -12,7 +11,8 @@
 #include <string.h>
 #include <unistd.h>
 
-constexpr auto kKeys = 500;
+// musl only has  128 keys
+constexpr auto kKeys = 100;
 
 int main(int argc, char **argv) {
   __hwasan_enable_allocator_tagging();

@thurstond
Copy link
Contributor

There's a flag:

LSAN_FLAG(bool, use_ld_allocations, true,
          "Root set: mark as reachable all allocations made from dynamic "
          "linker. This was the old way to handle dynamic TLS, and will "
          "be removed soon. Do not use this flag.")

Obviously we shouldn't use this flag, but I wonder if something like that would be better than specifically suppressing *dlerror* (are other dl* functions going to break at some point?).

@fmayer
Copy link
Contributor Author

fmayer commented Jun 4, 2025

There's a flag:

LSAN_FLAG(bool, use_ld_allocations, true,
          "Root set: mark as reachable all allocations made from dynamic "
          "linker. This was the old way to handle dynamic TLS, and will "
          "be removed soon. Do not use this flag.")

Obviously we shouldn't use this flag, but I wonder if something like that would be better than specifically suppressing *dlerror* (are other dl* functions going to break at some point?).

Yeah, it would be better to fix the root cause. But until then, this exclusion makes sense IMO. WDYT?

@thurstond
Copy link
Contributor

Yeah, it would be better to fix the root cause. But until then, this exclusion makes sense IMO. WDYT?

SGTM.

fmayer added 2 commits June 4, 2025 20:03
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@fmayer fmayer changed the base branch from users/fmayer/spr/main.lsan-skip-leaks-from-dlerror to main June 5, 2025 03:04
@fmayer fmayer merged commit 0eccf13 into main Jun 5, 2025
8 of 15 checks passed
@fmayer fmayer deleted the users/fmayer/spr/lsan-skip-leaks-from-dlerror branch June 5, 2025 03:04
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
We have known false positives, and the return value is never
user-managed anyway.
DhruvSrivastavaX pushed a commit to DhruvSrivastavaX/lldb-for-aix that referenced this pull request Jun 12, 2025
We have known false positives, and the return value is never
user-managed anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants