@@ -50,7 +50,10 @@ ur_result_t ShadowMemoryCPU::Setup() {
50
50
ShadowEnd = ShadowBegin + ShadowSize;
51
51
52
52
// 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 );
54
57
if (URes != UR_RESULT_SUCCESS) {
55
58
getContext ()->logger .error (" EnqueuePoisonShadow(NullPointerRZ): {}" ,
56
59
URes);
@@ -111,9 +114,12 @@ ur_result_t ShadowMemoryGPU::Setup() {
111
114
}
112
115
113
116
// 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;
114
120
ManagedQueue Queue (Context, Device);
115
-
116
- Result = EnqueuePoisonShadow (Queue, 0 , 1 , kNullPointerRedzoneMagic );
121
+ Result = EnqueuePoisonShadow (Queue, 0 , NullptrRedzoneSize,
122
+ kNullPointerRedzoneMagic );
117
123
if (Result != UR_RESULT_SUCCESS) {
118
124
getContext ()->logger .error (" EnqueuePoisonShadow(NullPointerRZ): {}" ,
119
125
Result);
0 commit comments