Skip to content

Commit 4444135

Browse files
authored
[UR][DeviceASAN] Fix incorrect symbolizer output for shared libraries (#15797)
UR Part: oneapi-src/unified-runtime#2229
1 parent be1679b commit 4444135

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// REQUIRES: linux, cpu
2+
// RUN: %{build} %device_asan_flags -O0 -g -fPIC -shared -DSHARED_LIB -o %t.so
3+
// RUN: %{build} %device_asan_flags -O0 -g -fPIC -Wl,-rpath,. %t.so -o %t
4+
// RUN: %{run} %t 2>&1 | FileCheck %s
5+
#include <sycl/detail/core.hpp>
6+
7+
#include <sycl/usm.hpp>
8+
9+
#if defined(SHARED_LIB)
10+
void test(sycl::queue &Q, size_t N) {
11+
auto *array = sycl::malloc_device<char>(N, Q);
12+
13+
Q.submit([&](sycl::handler &h) {
14+
h.parallel_for<class MyKernelR_4>(
15+
sycl::nd_range<1>(N, 1),
16+
[=](sycl::nd_item<1> item) { ++array[item.get_global_id(0)]; });
17+
}).wait();
18+
}
19+
20+
#else
21+
22+
void test(sycl::queue &Q, size_t N);
23+
24+
int main() {
25+
sycl::queue Q;
26+
constexpr std::size_t N = 12;
27+
28+
test(Q, N);
29+
30+
// CHECK: ERROR: DeviceSanitizer: detected memory leaks of Device USM
31+
// CHECK: Direct leak of 12 byte(s) at {{0x.*}} allocated from:
32+
// CHECK: in test{{.*memory-leak-shared-lib.cpp:}}[[@LINE-21]]
33+
34+
return 0;
35+
}
36+
37+
#endif

0 commit comments

Comments
 (0)