@@ -203,13 +203,13 @@ inline uptr MemToShadow_PVC(uptr addr, uint32_t as,
203
203
return shadow_ptr;
204
204
} else if (as == ADDRESS_SPACE_LOCAL) { // local
205
205
const auto shadow_offset = launch_info->LocalShadowOffset ;
206
- if (shadow_offset == 0 ) {
206
+ const auto wid = WorkGroupLinearId ();
207
+ if (shadow_offset == 0 || wid >= ASAN_MAX_WG_LOCAL) {
207
208
return 0 ;
208
209
}
209
210
210
211
// The size of SLM is 128KB on PVC
211
212
constexpr unsigned SLM_SIZE = 128 * 1024 ;
212
- const auto wid = WorkGroupLinearId ();
213
213
214
214
uptr shadow_ptr = shadow_offset + ((wid * SLM_SIZE) >> ASAN_SHADOW_SCALE) +
215
215
((addr & (SLM_SIZE - 1 )) >> ASAN_SHADOW_SCALE);
@@ -494,6 +494,9 @@ void ReportMisalignError(uptr addr, uint32_t as, bool is_recover,
494
494
const DebugInfo *debug) {
495
495
496
496
auto *shadow = (__SYCL_GLOBAL__ s8 *)MemToShadow (addr, as, debug);
497
+ if (!shadow)
498
+ return ;
499
+
497
500
while (*shadow >= 0 ) {
498
501
++shadow;
499
502
}
@@ -710,6 +713,9 @@ __asan_set_shadow_static_local(uptr ptr, size_t size,
710
713
// Set red zone
711
714
{
712
715
auto shadow_address = MemToShadow (ptr + aligned_size, ADDRESS_SPACE_LOCAL);
716
+ if (!shadow_address)
717
+ return ;
718
+
713
719
auto count = (size_with_redzone - aligned_size) >> ASAN_SHADOW_SCALE;
714
720
715
721
ASAN_DEBUG (__spirv_ocl_printf (__mem_set_shadow_local, shadow_address,
@@ -726,6 +732,9 @@ __asan_set_shadow_static_local(uptr ptr, size_t size,
726
732
auto user_end = ptr + size;
727
733
auto *shadow_end =
728
734
(__SYCL_GLOBAL__ s8 *)MemToShadow (user_end, ADDRESS_SPACE_LOCAL);
735
+ if (!shadow_end)
736
+ return ;
737
+
729
738
auto value = user_end - RoundDownTo (user_end, ASAN_SHADOW_GRANULARITY) + 1 ;
730
739
*shadow_end = value;
731
740
@@ -748,7 +757,11 @@ __asan_unpoison_shadow_static_local(uptr ptr, size_t size,
748
757
ASAN_DEBUG (__spirv_ocl_printf (__mem_unpoison_shadow_static_local_begin));
749
758
750
759
auto shadow_begin = MemToShadow (ptr + size, ADDRESS_SPACE_LOCAL);
760
+ if (!shadow_begin)
761
+ return ;
751
762
auto shadow_end = MemToShadow (ptr + size_with_redzone, ADDRESS_SPACE_LOCAL);
763
+ if (!shadow_end)
764
+ return ;
752
765
753
766
ASAN_DEBUG (
754
767
__spirv_ocl_printf (__mem_set_shadow_local, shadow_begin, shadow_end, 0 ));
0 commit comments