Skip to content

[NFC][sanitizer] Commit test for #106912 #108289

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

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Sep 11, 2024

Almost all sanitizers already support the test.

memprof,rtsan,nsan are not tested as part of
sanitizer_common, but we should keep them here to
show up when it happen.

@llvmbot
Copy link
Member

llvmbot commented Sep 11, 2024

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

Author: Vitaly Buka (vitalybuka)

Changes

Almost all sanitizers already support the test.

  • Tsan does not use DlsymAlloc yet.
  • Lsan will support with #106912.

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

1 Files Affected:

  • (added) compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.cpp (+49)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.cpp b/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.cpp
new file mode 100644
index 00000000000000..9d61a30d22c1bf
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.cpp
@@ -0,0 +1,49 @@
+// RUN: %clangxx -O0 -pthread %s -o %t && %run %t
+
+// FIXME: TSAN does not use DlsymAlloc.
+// UNSUPPORTED: tsan
+
+// FIXME: https://github.com/llvm/llvm-project/pull/106912
+// XFAIL: lsan
+
+#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(nullptr);
+
+  return "";
+}
+
+extern "C" const char *__asan_default_options()
+    __attribute__((disable_sanitizer_instrumentation)) {
+  return test();
+}
+
+extern "C" const char *__lsan_default_options()
+    __attribute__((disable_sanitizer_instrumentation)) {
+  return test();
+}
+
+extern "C" const char *__msan_default_options()
+    __attribute__((disable_sanitizer_instrumentation)) {
+  return test();
+}
+
+extern "C" const char *__tsan_default_options()
+    __attribute__((disable_sanitizer_instrumentation)) {
+  return test();
+}
+
+extern "C" const char *__hwasan_default_options()
+    __attribute__((disable_sanitizer_instrumentation)) {
+  return test();
+}
+
+int main(int argc, char **argv) { return 0; }

Copy link

github-actions bot commented Sep 11, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Created using spr 1.3.4
vitalybuka and others added 4 commits September 11, 2024 13:49
Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4

[skip ci]
Created using spr 1.3.4
@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.nfcsanitizer-commit-test-for-106912 to main September 11, 2024 21:01
@vitalybuka vitalybuka merged commit 1797174 into main Sep 11, 2024
7 of 9 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/nfcsanitizer-commit-test-for-106912 branch September 11, 2024 21:44
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Jan 13, 2025
Almost all sanitizers already support the test.
* Tsan does not use DlsymAlloc yet.
* Lsan will support with llvm#106912.

memprof,rtsan,nsan are not tested as part of
sanitizer_common, but we should keep them here to
show up when it happen.

---------

Co-authored-by: Xiaofeng Tian <[email protected]>
(cherry picked from commit 1797174)
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.

4 participants