Skip to content

[rtsan] Fix RTTI issue, make a better c test #108720

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 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler-rt/lib/rtsan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ set(RTSAN_LINK_LIBS
${COMPILER_RT_UNWINDER_LINK_LIBS}
${COMPILER_RT_CXX_LINK_LIBS})

append_rtti_flag(OFF RTSAN_CFLAGS)

if(APPLE)
add_compiler_rt_object_libraries(RTRtsan
OS ${SANITIZER_COMMON_SUPPORTED_OS}
Expand Down
1 change: 0 additions & 1 deletion compiler-rt/test/rtsan/basic.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: %clangxx -fsanitize=realtime %s -o %t
// RUN: %clang -fsanitize=realtime %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: ios

Expand Down
28 changes: 28 additions & 0 deletions compiler-rt/test/rtsan/sanity_check_pure_c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// RUN: %clang -fsanitize=realtime %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: %clang %s -o %t
// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE
#ifdef __cplusplus
# error "This test must be built in C mode"
#endif

#include <stdio.h>
#include <stdlib.h>

// Check that we can build and run C code.

void nonblocking_function(void) __attribute__((nonblocking));

void nonblocking_function(void) __attribute__((nonblocking)) {
void *ptr = malloc(2);
printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc
}

int main() {
nonblocking_function();
printf("Done\n");
return 0;
}

// CHECK: ==ERROR: RealtimeSanitizer
// CHECK-NO-SANITIZE: Done
Loading