Files
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

83 lines
2.6 KiB
C++

// Checks that the ASan debugging API for getting report information
// returns correct values.
// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
#include <sanitizer/asan_interface.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
// Disable stderr buffering. Needed on Windows.
setvbuf(stderr, NULL, _IONBF, 0);
char *heap_ptr = (char *)malloc(10);
free(heap_ptr);
int present = __asan_report_present();
fprintf(stderr, "%s\n", (present == 0) ? "no report" : "");
// CHECK: no report
heap_ptr[0] = 'A'; // BOOM
return 0;
}
// If we use %p with MS CRTs, it comes out all upper case. Use %08x to get
// lowercase hex.
#ifdef _WIN32
# ifdef _WIN64
# define PTR_FMT "0x%08llx"
# else
# define PTR_FMT "0x%08x"
# endif
// Solaris libc omits the leading 0x.
#elif defined(__sun__) && defined(__svr4__)
# define PTR_FMT "0x%p"
#else
# define PTR_FMT "%p"
#endif
// Required for dyld macOS 12.0+
#if (__APPLE__)
__attribute__((weak))
#endif
extern "C" void
__asan_on_error() {
int present = __asan_report_present();
void *pc = __asan_get_report_pc();
void *bp = __asan_get_report_bp();
void *sp = __asan_get_report_sp();
void *addr = __asan_get_report_address();
int is_write = __asan_get_report_access_type();
size_t access_size = __asan_get_report_access_size();
const char *description = __asan_get_report_description();
fprintf(stderr, "%s\n", (present == 1) ? "report" : "");
// CHECK: report
fprintf(stderr, "pc: " PTR_FMT "\n", pc);
// CHECK: pc: 0x[[PC:[0-9a-f]+]]
fprintf(stderr, "bp: " PTR_FMT "\n", bp);
// CHECK: bp: 0x[[BP:[0-9a-f]+]]
fprintf(stderr, "sp: " PTR_FMT "\n", sp);
// CHECK: sp: 0x[[SP:[0-9a-f]+]]
fprintf(stderr, "addr: " PTR_FMT "\n", addr);
// CHECK: addr: 0x[[ADDR:[0-9a-f]+]]
fprintf(stderr, "type: %s\n", (is_write ? "write" : "read"));
// CHECK: type: write
fprintf(stderr, "access_size: %zu\n", access_size);
// CHECK: access_size: 1
fprintf(stderr, "description: %s\n", description);
// CHECK: description: heap-use-after-free
const void *addr2 = NULL;
size_t size2 = 0;
int is_dest = __asan_get_report_dest_address(&addr2, &size2);
fprintf(stderr, "is_dest: %d, addr2: " PTR_FMT ", size2: %zu\n", is_dest,
addr2, size2);
// CHECK: is_dest: 1, addr2: 0x[[ADDR]], size2: 1
int is_src = __asan_get_report_src_address(&addr2, &size2);
fprintf(stderr, "is_src: %d\n", is_src);
// CHECK: is_src: 0
}
// CHECK: AddressSanitizer: heap-use-after-free on address {{0x0*}}[[ADDR]] at pc {{0x0*}}[[PC]] bp {{0x0*}}[[BP]] sp {{0x0*}}[[SP]]
// CHECK: WRITE of size 1 at {{0x0*}}[[ADDR]] thread T0