14
14
15
15
#include " asan_interceptor.hpp"
16
16
#include " asan_ddi.hpp"
17
- #include " asan_options.hpp"
18
17
#include " asan_quarantine.hpp"
19
18
#include " asan_report.hpp"
20
19
#include " asan_shadow.hpp"
21
20
#include " asan_validator.hpp"
21
+ #include " sanitizer_common/sanitizer_options.hpp"
22
22
#include " sanitizer_common/sanitizer_stacktrace.hpp"
23
23
#include " sanitizer_common/sanitizer_utils.hpp"
24
24
25
25
namespace ur_sanitizer_layer {
26
26
namespace asan {
27
27
28
28
AsanInterceptor::AsanInterceptor () {
29
- if (getOptions () .MaxQuarantineSizeMB ) {
29
+ if (getContext ()-> Options .MaxQuarantineSizeMB ) {
30
30
m_Quarantine = std::make_unique<Quarantine>(
31
- static_cast < uint64_t >( getOptions () .MaxQuarantineSizeMB ) * 1024 * 1024 );
31
+ getContext ()-> Options .MaxQuarantineSizeMB * 1024 * 1024 );
32
32
}
33
33
}
34
34
@@ -90,8 +90,7 @@ ur_result_t AsanInterceptor::allocateMemory(ur_context_handle_t Context,
90
90
Alignment = MinAlignment;
91
91
}
92
92
93
- uptr RZLog =
94
- ComputeRZLog (Size , getOptions ().MinRZSize , getOptions ().MaxRZSize );
93
+ uptr RZLog = ComputeRZLog (Size , getContext ()->Options .MinRZSize );
95
94
uptr RZSize = RZLog2Size (RZLog);
96
95
uptr RoundedSize = RoundUpTo (Size , Alignment);
97
96
uptr NeededSize = RoundedSize + RZSize * 2 ;
@@ -175,7 +174,7 @@ ur_result_t AsanInterceptor::releaseMemory(ur_context_handle_t Context,
175
174
if (!AllocInfoItOp) {
176
175
// "Addr" might be a host pointer
177
176
ReportBadFree (Addr, GetCurrentBacktrace (), nullptr );
178
- if (getOptions () .HaltOnError ) {
177
+ if (getContext ()-> Options .HaltOnError ) {
179
178
exitWithErrors ();
180
179
}
181
180
return UR_RESULT_SUCCESS;
@@ -193,23 +192,23 @@ ur_result_t AsanInterceptor::releaseMemory(ur_context_handle_t Context,
193
192
// "Addr" might be a host pointer
194
193
ReportBadFree (Addr, GetCurrentBacktrace (), nullptr );
195
194
}
196
- if (getOptions () .HaltOnError ) {
195
+ if (getContext ()-> Options .HaltOnError ) {
197
196
exitWithErrors ();
198
197
}
199
198
return UR_RESULT_SUCCESS;
200
199
}
201
200
202
201
if (Addr != AllocInfo->UserBegin ) {
203
202
ReportBadFree (Addr, GetCurrentBacktrace (), AllocInfo);
204
- if (getOptions () .HaltOnError ) {
203
+ if (getContext ()-> Options .HaltOnError ) {
205
204
exitWithErrors ();
206
205
}
207
206
return UR_RESULT_SUCCESS;
208
207
}
209
208
210
209
if (AllocInfo->IsReleased ) {
211
210
ReportDoubleFree (Addr, GetCurrentBacktrace (), AllocInfo);
212
- if (getOptions () .HaltOnError ) {
211
+ if (getContext ()-> Options .HaltOnError ) {
213
212
exitWithErrors ();
214
213
}
215
214
return UR_RESULT_SUCCESS;
@@ -736,7 +735,7 @@ ur_result_t AsanInterceptor::prepareLaunch(
736
735
LocalMemoryUsage, PrivateMemoryUsage);
737
736
738
737
// Validate pointer arguments
739
- if (getOptions () .DetectKernelArguments ) {
738
+ if (getContext ()-> Options .DetectKernelArguments ) {
740
739
for (const auto &[ArgIndex, PtrPair] : KernelInfo.PointerArgs ) {
741
740
auto Ptr = PtrPair.first ;
742
741
if (Ptr == nullptr ) {
@@ -813,10 +812,10 @@ ur_result_t AsanInterceptor::prepareLaunch(
813
812
LaunchInfo.Data .Host .GlobalShadowOffset = DeviceInfo->Shadow ->ShadowBegin ;
814
813
LaunchInfo.Data .Host .GlobalShadowOffsetEnd = DeviceInfo->Shadow ->ShadowEnd ;
815
814
LaunchInfo.Data .Host .DeviceTy = DeviceInfo->Type ;
816
- LaunchInfo.Data .Host .Debug = getOptions () .Debug ? 1 : 0 ;
815
+ LaunchInfo.Data .Host .Debug = getContext ()-> Options .Debug ? 1 : 0 ;
817
816
818
817
// Write shadow memory offset for local memory
819
- if (getOptions () .DetectLocals ) {
818
+ if (getContext ()-> Options .DetectLocals ) {
820
819
if (DeviceInfo->Shadow ->AllocLocalShadow (
821
820
Queue, NumWG, LaunchInfo.Data .Host .LocalShadowOffset ,
822
821
LaunchInfo.Data .Host .LocalShadowOffsetEnd ) != UR_RESULT_SUCCESS) {
@@ -836,7 +835,7 @@ ur_result_t AsanInterceptor::prepareLaunch(
836
835
}
837
836
838
837
// Write shadow memory offset for private memory
839
- if (getOptions () .DetectPrivates ) {
838
+ if (getContext ()-> Options .DetectPrivates ) {
840
839
if (DeviceInfo->Shadow ->AllocPrivateShadow (
841
840
Queue, NumWG, LaunchInfo.Data .Host .PrivateShadowOffset ,
842
841
LaunchInfo.Data .Host .PrivateShadowOffsetEnd ) != UR_RESULT_SUCCESS) {
@@ -928,7 +927,7 @@ ContextInfo::~ContextInfo() {
928
927
assert (URes == UR_RESULT_SUCCESS);
929
928
930
929
// check memory leaks
931
- if (getAsanInterceptor ()->getOptions () .DetectLeaks &&
930
+ if (getContext ()->Options .DetectLeaks &&
932
931
getAsanInterceptor ()->isNormalExit ()) {
933
932
std::vector<AllocationIterator> AllocInfos =
934
933
getAsanInterceptor ()->findAllocInfoByContext (Handle );
0 commit comments