[compiler-rt] 0efc167 - [test][sanitizer] Convert test from C++ to C

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 22:42:54 PST 2023


Author: Vitaly Buka
Date: 2023-12-12T22:42:41-08:00
New Revision: 0efc1674d914bd419cd9e031a12b2e1036931c67

URL: https://github.com/llvm/llvm-project/commit/0efc1674d914bd419cd9e031a12b2e1036931c67
DIFF: https://github.com/llvm/llvm-project/commit/0efc1674d914bd419cd9e031a12b2e1036931c67.diff

LOG: [test][sanitizer] Convert test from C++ to C

This avoids internal libstdc++ leaks.

Added: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c

Modified: 
    

Removed: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
similarity index 90%
rename from compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
rename to compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
index ee9629adc1938c..cbdf9ee00cff5e 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
@@ -1,4 +1,4 @@
-// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
+// RUN: %clang -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
 
 // UNSUPPORTED: asan, lsan, hwasan
 
@@ -28,10 +28,11 @@ pthread_barrier_t bar;
 // start with locked internal mutexes.
 void ShouldNotDeadlock() {
   // Don't bother with leaks, we try to trigger allocator or lsan deadlock.
-  __lsan::ScopedDisabler disable;
-  char *volatile p = new char[10];
+  __lsan_disable();
+  void *volatile p = malloc(10);
   __lsan_do_recoverable_leak_check();
-  delete[] p;
+  free(p);
+  __lsan_enable();
 }
 
 // Prevent stack buffer cleanup by instrumentation.
@@ -59,7 +60,7 @@ NOSAN static void *inchild(void *arg) {
 int main(void) {
   pid_t pid;
 
-  pthread_barrier_init(&bar, nullptr, 2);
+  pthread_barrier_init(&bar, NULL, 2);
   pthread_t thread_id;
   while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
   }


        


More information about the llvm-commits mailing list