1// clang-format off
2// RUN: %libomptarget-compileopt-generic
3// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK
4// RUN: %libomptarget-compileopt-generic -g
5// RUN: %not --crash env -u LLVM_DISABLE_SYMBOLIZATION OFFLOAD_TRACK_ALLOCATION_TRACES=1 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefixes=CHECK
6// clang-format on
7
8// UNSUPPORTED: aarch64-unknown-linux-gnu
9// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
10// UNSUPPORTED: x86_64-unknown-linux-gnu
11// UNSUPPORTED: x86_64-unknown-linux-gnu-LTO
12// UNSUPPORTED: s390x-ibm-linux-gnu
13// UNSUPPORTED: s390x-ibm-linux-gnu-LTO
14
15#include <omp.h>
16
17int main(void) {
18 void *Ptr1 = omp_target_alloc(8, 0);
19#pragma omp parallel num_threads(4)
20 omp_target_free(Ptr1, 0);
21}
22
23// CHECK: OFFLOAD ERROR: double-free of device memory: 0x
24// CHECK dataDelete
25// CHECK: omp_target_free
26//
27// CHECK: Last deallocation:
28// CHECK: dataDelete
29// CHECK: omp_target_free
30
31// CHECK: Last allocation of size 8 -> device pointer
32// CHECK: dataAlloc
33// CHECK: omp_target_alloc
34

source code of offload/test/sanitizer/double_free_racy.c