Skip to content

Commit 0efc167

Browse files
committed
[test][sanitizer] Convert test from C++ to C
This avoids internal libstdc++ leaks.
1 parent 215c565 commit 0efc167

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.cpp renamed to compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
1+
// RUN: %clang -O0 %s -o %t && %env_tool_opts=die_after_fork=0 %run %t
22

33
// UNSUPPORTED: asan, lsan, hwasan
44

@@ -28,10 +28,11 @@ pthread_barrier_t bar;
2828
// start with locked internal mutexes.
2929
void ShouldNotDeadlock() {
3030
// Don't bother with leaks, we try to trigger allocator or lsan deadlock.
31-
__lsan::ScopedDisabler disable;
32-
char *volatile p = new char[10];
31+
__lsan_disable();
32+
void *volatile p = malloc(10);
3333
__lsan_do_recoverable_leak_check();
34-
delete[] p;
34+
free(p);
35+
__lsan_enable();
3536
}
3637

3738
// Prevent stack buffer cleanup by instrumentation.
@@ -59,7 +60,7 @@ NOSAN static void *inchild(void *arg) {
5960
int main(void) {
6061
pid_t pid;
6162

62-
pthread_barrier_init(&bar, nullptr, 2);
63+
pthread_barrier_init(&bar, NULL, 2);
6364
pthread_t thread_id;
6465
while (pthread_create(&thread_id, 0, &inparent, 0) != 0) {
6566
}

0 commit comments

Comments
 (0)