Skip to content

Commit 0b5d8f9

Browse files
authored
Merge pull request #2250 from yingcong-wu/yc-PR/1028-leak-check-option
[DevAsan] Add an option to enable/disable leak detection
2 parents 60f2ce2 + 2284149 commit 0b5d8f9

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

source/loader/layers/sanitizer/asan/asan_interceptor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ ContextInfo::~ContextInfo() {
932932
assert(Result == UR_RESULT_SUCCESS);
933933

934934
// check memory leaks
935-
if (getAsanInterceptor()->isNormalExit()) {
935+
if (getAsanInterceptor()->getOptions().DetectLeaks &&
936+
getAsanInterceptor()->isNormalExit()) {
936937
std::vector<AllocationIterator> AllocInfos =
937938
getAsanInterceptor()->findAllocInfoByContext(Handle);
938939
for (const auto &It : AllocInfos) {

source/loader/layers/sanitizer/asan/asan_interceptor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ class AsanInterceptor {
310310
ur_result_t registerSpirKernels(ur_program_handle_t Program);
311311

312312
private:
313+
// m_Options may be used in other places, place it at the top
314+
AsanOptions m_Options;
313315
std::unordered_map<ur_context_handle_t, std::shared_ptr<ContextInfo>>
314316
m_ContextMap;
315317
ur_shared_mutex m_ContextMapMutex;
@@ -335,8 +337,6 @@ class AsanInterceptor {
335337

336338
std::unique_ptr<Quarantine> m_Quarantine;
337339

338-
AsanOptions m_Options;
339-
340340
std::unordered_set<ur_adapter_handle_t> m_Adapters;
341341
ur_shared_mutex m_AdaptersMutex;
342342

source/loader/layers/sanitizer/asan/asan_options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ AsanOptions::AsanOptions() {
8888
SetBoolOption("detect_locals", DetectLocals);
8989
SetBoolOption("detect_privates", DetectPrivates);
9090
SetBoolOption("print_stats", PrintStats);
91+
SetBoolOption("detect_leaks", DetectLeaks);
9192

9293
auto KV = OptionsEnvMap->find("quarantine_size_mb");
9394
if (KV != OptionsEnvMap->end()) {

source/loader/layers/sanitizer/asan/asan_options.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct AsanOptions {
2626
bool DetectPrivates = true;
2727
bool PrintStats = false;
2828
bool DetectKernelArguments = true;
29+
bool DetectLeaks = true;
2930

3031
explicit AsanOptions();
3132
};

0 commit comments

Comments
 (0)