CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
// RUN: %clangxx -fsanitize=realtime %s -o %t
|
|
// RUN: %env_rtsan_opts="halt_on_error=false" %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-RTSAN,CHECK
|
|
|
|
// RUN: %clangxx %s -o %t
|
|
// RUN: %run %t 2>&1 | FileCheck %s
|
|
|
|
// UNSUPPORTED: ios
|
|
|
|
// Intent: Ensure the `syscall` call behaves in the same way with/without the
|
|
// sanitizer disabled
|
|
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/syscall.h>
|
|
#include <sys/types.h>
|
|
#include <unistd.h>
|
|
|
|
const char *GetTemporaryFilePath() { return "/tmp/rtsan_syscall_test.txt"; }
|
|
|
|
void custom_assert(bool condition, const char *message) {
|
|
if (!condition) {
|
|
fprintf(stderr, "ASSERTION FAILED: %s\n", message);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
class ScopedFileCleanup {
|
|
public:
|
|
[[nodiscard]] ScopedFileCleanup() = default;
|
|
~ScopedFileCleanup() {
|
|
if (access(GetTemporaryFilePath(), F_OK) != -1)
|
|
unlink(GetTemporaryFilePath());
|
|
}
|
|
};
|
|
|
|
// Apple has deprecated `syscall`, ignore that error
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
int main() [[clang::nonblocking]] {
|
|
ScopedFileCleanup cleanup;
|
|
|
|
{
|
|
int fd = syscall(SYS_openat, AT_FDCWD, GetTemporaryFilePath(),
|
|
O_CREAT | O_WRONLY, 0644);
|
|
|
|
custom_assert(fd != -1, "Failed to open file - write");
|
|
|
|
int written = syscall(SYS_write, fd, "Hello, world!", 13);
|
|
custom_assert(written == 13, "Failed to write to file");
|
|
|
|
custom_assert(syscall(SYS_close, fd) == 0, "Failed to close file - write");
|
|
}
|
|
|
|
{
|
|
int fd = syscall(SYS_openat, AT_FDCWD, GetTemporaryFilePath(), O_RDONLY);
|
|
custom_assert(fd != -1, "Failed to open file - read");
|
|
|
|
char buffer[13];
|
|
int read = syscall(SYS_read, fd, buffer, 13);
|
|
custom_assert(read == 13, "Failed to read from file");
|
|
|
|
custom_assert(memcmp(buffer, "Hello, world!", 13) == 0,
|
|
"Read data does not match written data");
|
|
|
|
custom_assert(syscall(SYS_close, fd) == 0, "Failed to close file - read");
|
|
}
|
|
|
|
unlink(GetTemporaryFilePath());
|
|
printf("DONE\n");
|
|
}
|
|
#pragma clang diagnostic pop
|
|
|
|
// CHECK-NOT: ASSERTION FAILED
|
|
// CHECK-RTSAN-COUNT-6: Intercepted call to real-time unsafe function `syscall`
|
|
|
|
// CHECK: DONE
|