From 27173c1ec6dd7d69490912ad90c028ba8a88ab41 Mon Sep 17 00:00:00 2001 From: "Wu, Yingcong" Date: Fri, 19 Jul 2024 01:58:56 -0700 Subject: [PATCH 1/2] change it to static --- source/loader/layers/sanitizer/asan_interceptor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/loader/layers/sanitizer/asan_interceptor.cpp b/source/loader/layers/sanitizer/asan_interceptor.cpp index fc0b312e5f..c1d059cddf 100644 --- a/source/loader/layers/sanitizer/asan_interceptor.cpp +++ b/source/loader/layers/sanitizer/asan_interceptor.cpp @@ -709,7 +709,10 @@ ur_result_t SanitizerInterceptor::prepareLaunch( // Write debug // We use "uint64_t" here because EnqueueWriteGlobal will fail when it's "uint32_t" - uint64_t Debug = Options(logger).Debug ? 1 : 0; + // Because EnqueueWriteGlobal is a async write, so + // we need to extend its lifetime + static uint64_t Debug; + Debug = Options(logger).Debug ? 1 : 0; EnqueueWriteGlobal(kSPIR_AsanDebug, &Debug, sizeof(Debug)); // Write shadow memory offset for global memory From 3e044024ea139dcf7314aafa19ddd97db4cb6f01 Mon Sep 17 00:00:00 2001 From: "Wu, Yingcong" Date: Sun, 21 Jul 2024 22:54:37 -0700 Subject: [PATCH 2/2] only init once --- source/loader/layers/sanitizer/asan_interceptor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/loader/layers/sanitizer/asan_interceptor.cpp b/source/loader/layers/sanitizer/asan_interceptor.cpp index c1d059cddf..34d312d134 100644 --- a/source/loader/layers/sanitizer/asan_interceptor.cpp +++ b/source/loader/layers/sanitizer/asan_interceptor.cpp @@ -711,8 +711,7 @@ ur_result_t SanitizerInterceptor::prepareLaunch( // We use "uint64_t" here because EnqueueWriteGlobal will fail when it's "uint32_t" // Because EnqueueWriteGlobal is a async write, so // we need to extend its lifetime - static uint64_t Debug; - Debug = Options(logger).Debug ? 1 : 0; + static uint64_t Debug = Options(logger).Debug ? 1 : 0; EnqueueWriteGlobal(kSPIR_AsanDebug, &Debug, sizeof(Debug)); // Write shadow memory offset for global memory