Skip to content

Commit a61fe8e

Browse files
committed
add option
1 parent eddfd8e commit a61fe8e

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

source/loader/layers/sanitizer/asan_interceptor.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,13 +837,15 @@ ContextInfo::~ContextInfo() {
837837
getContext()->urDdiTable.Context.pfnRelease(Handle);
838838
assert(Result == UR_RESULT_SUCCESS);
839839

840-
// check memory leaks
841-
std::vector<AllocationIterator> AllocInfos =
842-
getContext()->interceptor->findAllocInfoByContext(Handle);
843-
for (const auto &It : AllocInfos) {
844-
const auto &[_, AI] = *It;
845-
if (!AI->IsReleased) {
846-
ReportMemoryLeak(AI);
840+
if (getOptions().DetectLeaks) {
841+
// check memory leaks
842+
std::vector<AllocationIterator> AllocInfos =
843+
getContext()->interceptor->findAllocInfoByContext(Handle);
844+
for (const auto &It : AllocInfos) {
845+
const auto &[_, AI] = *It;
846+
if (!AI->IsReleased) {
847+
ReportMemoryLeak(AI);
848+
}
847849
}
848850
}
849851
}

source/loader/layers/sanitizer/asan_options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ AsanOptions::AsanOptions() {
8585
SetBoolOption("detect_locals", DetectLocals);
8686
SetBoolOption("detect_privates", DetectPrivates);
8787
SetBoolOption("print_stats", PrintStats);
88+
SetBoolOption("detect_leaks", DetectLeaks);
8889

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

source/loader/layers/sanitizer/asan_options.hpp

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

2930
explicit AsanOptions();
3031
};

0 commit comments

Comments
 (0)