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
108 lines
4.2 KiB
C++
108 lines
4.2 KiB
C++
// RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
|
|
|
|
// RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
|
|
// XFAIL: msvc
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
|
|
int foo(char *p, char *q) {
|
|
return p > q;
|
|
}
|
|
|
|
char global1[100] = {}, global2[100] = {};
|
|
char __attribute__((used)) smallest_global[5] = {};
|
|
char small_global[7] = {};
|
|
char __attribute__((used)) little_global[10] = {};
|
|
char __attribute__((used)) medium_global[4000] = {};
|
|
char large_global[5000] = {};
|
|
char __attribute__((used)) largest_global[6000] = {};
|
|
|
|
int main() {
|
|
// Heap allocated memory.
|
|
char *heap1 = (char *)malloc(42);
|
|
char *heap2 = (char *)malloc(42);
|
|
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(heap1, heap2);
|
|
free(heap1);
|
|
free(heap2);
|
|
|
|
heap1 = (char *)malloc(1024);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(heap1, heap1 + 1025);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(heap1 + 1024, heap1 + 1025);
|
|
free(heap1);
|
|
|
|
heap1 = (char *)malloc(4096);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(heap1, heap1 + 4097);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(heap1, 0);
|
|
|
|
// Global variables.
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(&global1[0], &global2[10]);
|
|
|
|
char *p = &small_global[0];
|
|
foo(p, p); // OK
|
|
foo(p, p + 7); // OK
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p, p + 8);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p - 1, p);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p, p - 1);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p - 1, p + 8);
|
|
|
|
p = &large_global[0];
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p - 1, p);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p, p - 1);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p, &global1[0]);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p, &small_global[0]);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(p, 0);
|
|
|
|
// Stack variables.
|
|
char stack1, stack2;
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(&stack1, &stack2);
|
|
|
|
// Mixtures.
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(heap1, &stack1);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
foo(heap1, &global1[0]);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
foo(&stack1, &global1[0]);
|
|
// CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
|
|
// CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-compare-errors.cpp:[[@LINE+1]]
|
|
foo(&stack1, 0);
|
|
|
|
free(heap1);
|
|
|
|
return 0;
|
|
}
|