[llvm-branch-commits] [compiler-rt] release/19.x: [test][compiler-rt] Mark dlsym_alloc.c as unsupported on macos (#108439) (PR #121100)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 25 01:34:47 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport 1797174ea6adab08474658f9c9748991d172321c ae0ed3d58600da9ec266bf86d0084775f561ba3a d9ed8b018df725faec4076a3efdfcbd7a24c99f0
Requested by: @<!-- -->nikic
---
Full diff: https://github.com/llvm/llvm-project/pull/121100.diff
2 Files Affected:
- (modified) compiler-rt/lib/lsan/lsan_interceptors.cpp (+2)
- (added) compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c (+60)
``````````diff
diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index b569c337e97641..efbf2fdfb0ab3f 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -77,6 +77,8 @@ INTERCEPTOR(void*, malloc, uptr size) {
}
INTERCEPTOR(void, free, void *p) {
+ if (UNLIKELY(!p))
+ return;
if (DlsymAlloc::PointerIsMine(p))
return DlsymAlloc::Free(p);
ENSURE_LSAN_INITED;
diff --git a/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c b/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c
new file mode 100644
index 00000000000000..7b5b9cf34a90f9
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c
@@ -0,0 +1,60 @@
+// RUN: %clang -O0 %s -o %t && %run %t
+
+// FIXME: TSAN does not use DlsymAlloc.
+// UNSUPPORTED: tsan
+// FIXME: investigate why this fails on macos
+// UNSUPPORTED: darwin
+
+#include <stdlib.h>
+
+const char *test() __attribute__((disable_sanitizer_instrumentation)) {
+ void *volatile p = malloc(3);
+ p = realloc(p, 7);
+ free(p);
+
+ p = calloc(3, 7);
+ free(p);
+
+ free(NULL);
+
+ return "";
+}
+
+const char *__asan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__hwasan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__lsan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__memprof_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__msan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__nsan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__rtsan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__tsan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+const char *__ubsan_default_options()
+ __attribute__((disable_sanitizer_instrumentation)) {
+ return test();
+}
+
+int main(int argc, char **argv) { return 0; }
``````````
</details>
https://github.com/llvm/llvm-project/pull/121100
More information about the llvm-branch-commits
mailing list