@@ -50,7 +50,10 @@ ur_result_t ShadowMemoryCPU::Setup() {
5050 ShadowEnd = ShadowBegin + ShadowSize;
5151
5252 // Set shadow memory for null pointer
53- auto URes = EnqueuePoisonShadow ({}, 0 , 1 , kNullPointerRedzoneMagic );
53+ // For CPU, we use a typical page size of 4K bytes.
54+ constexpr size_t NullptrRedzoneSize = 4096 ;
55+ auto URes = EnqueuePoisonShadow ({}, 0 , NullptrRedzoneSize,
56+ kNullPointerRedzoneMagic );
5457 if (URes != UR_RESULT_SUCCESS) {
5558 getContext ()->logger .error (" EnqueuePoisonShadow(NullPointerRZ): {}" ,
5659 URes);
@@ -111,9 +114,12 @@ ur_result_t ShadowMemoryGPU::Setup() {
111114 }
112115
113116 // Set shadow memory for null pointer
117+ // For GPU, wu use up to 1 page of shadow memory
118+ const size_t NullptrRedzoneSize =
119+ GetVirtualMemGranularity (Context, Device) << ASAN_SHADOW_SCALE;
114120 ManagedQueue Queue (Context, Device);
115-
116- Result = EnqueuePoisonShadow (Queue, 0 , 1 , kNullPointerRedzoneMagic );
121+ Result = EnqueuePoisonShadow (Queue, 0 , NullptrRedzoneSize,
122+ kNullPointerRedzoneMagic );
117123 if (Result != UR_RESULT_SUCCESS) {
118124 getContext ()->logger .error (" EnqueuePoisonShadow(NullPointerRZ): {}" ,
119125 Result);
0 commit comments