Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DeviceASAN] Fix quarantined memory and related info not release when context is released. #16467

Draft
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT)
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
set(UNIFIED_RUNTIME_REPO "https://github.com/yingcong-wu/unified-runtime.git")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake)

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
Expand Down
2 changes: 1 addition & 1 deletion sycl/cmake/modules/UnifiedRuntimeTag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Date: Fri Dec 6 15:24:04 2024 +0000
# Merge pull request #2352 from aarongreig/aaron/fixCoverity15-11
# Fix a number of issues from the latest coverity scan.
set(UNIFIED_RUNTIME_TAG aa72577da55571b15028dd1710e02a7ea4f62338)
set(UNIFIED_RUNTIME_TAG yc-test/1223-context-qanrantine)
36 changes: 23 additions & 13 deletions sycl/test-e2e/AddressSanitizer/use-after-free/quarantine-free.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,47 @@
///
/// In this test, the maximum size of quarantine cache is 5MB (5242880 bytes).

constexpr size_t N = 1024 * 1024;
constexpr size_t _1MB = 1024 * 1024;

int main() {
sycl::queue Q;
auto *array =
sycl::malloc_device<char>(N, Q); // allocated size: 1052672 <= 5242880
// 1. allocated size: {currently the size of all allocated memory} <= {maximum
// size of quarantine cache}"
// 2. 1052672 = 1024*1024 + 4096, 4096 is the size of red zone

// allocated size: 1MB+4KB(red zone) <= 5MB
auto *array = sycl::malloc_device<char>(_1MB, Q);
// CHECK: Alloc={{\[}}[[ADDR1:0x[0-9a-f]+]]
sycl::free(array, Q);

auto *temp =
sycl::malloc_device<char>(N, Q); // allocated size: 1052672*2 <= 5242880
// allocated size: 2MB+8KB < 5MB
auto *temp = sycl::malloc_device<char>(_1MB, Q);
// CHECK: Alloc={{\[}}[[ADDR2:0x[0-9a-f]+]]
sycl::free(temp, Q);

temp =
sycl::malloc_device<char>(N, Q); // allocated size: 1052672*3 <= 5242880
// allocated size: 3MB+12KB < 5MB
temp = sycl::malloc_device<char>(_1MB, Q);
// CHECK: Alloc={{\[}}[[ADDR3:0x[0-9a-f]+]]
sycl::free(temp, Q);

temp =
sycl::malloc_device<char>(N, Q); // allocated size: 1052672*4 <= 5242880
// allocated size: 4MB+16KB < 5MB
temp = sycl::malloc_device<char>(_1MB, Q);
// CHECK: Alloc={{\[}}[[ADDR4:0x[0-9a-f]+]]
sycl::free(temp, Q);

temp = sycl::malloc_device<char>(N, Q); // allocated size: 1052672*5 > 5242880
// allocated size: 5MB+20KB > 5MB, old allocation get actual freed
temp = sycl::malloc_device<char>(_1MB, Q);
// CHECK: Alloc={{\[}}[[ADDR5:0x[0-9a-f]+]]
sycl::free(temp, Q);
// CHECK: Quarantine Free: [[ADDR1]]
// After free, it becomes 4MB+16KB again

temp = sycl::malloc_device<char>(_1MB, Q);
// CHECK: Alloc={{\[}}[[ADDR6:0x[0-9a-f]+]]
sycl::free(temp, Q);
// CHECK: Quarantine Free: [[ADDR2]]

// CHECK-DAG: Quarantine Free: [[ADDR3]]
// CHECK-DAG: Quarantine Free: [[ADDR4]]
// CHECK-DAG: Quarantine Free: [[ADDR5]]
// CHECK-DAG: Quarantine Free: [[ADDR6]]

return 0;
}