Skip to content

Commit 27bc1c7

Browse files
committed
ensure ASAN_OPTS takes precedence
1 parent 20b4a5f commit 27bc1c7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler-rt/lib/asan/asan_flags.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,10 @@ void InitializeFlags() {
234234
// __sanitizer_register_weak_function.
235235
AddRegisterWeakFunctionCallback(
236236
reinterpret_cast<uptr>(__asan_default_options), []() {
237-
FlagParser asan_parser;
238-
239-
RegisterAsanFlags(&asan_parser, flags());
240-
RegisterCommonFlags(&asan_parser);
241-
asan_parser.ParseString(__asan_default_options());
242-
243-
DisplayHelpMessages(&asan_parser);
237+
// We call `InitializeDefaultFlags` again, instead of just parsing
238+
// `__asan_default_options` directly, to ensure that flags set through
239+
// `ASAN_OPTS` take precedence over those set through `__asan_default_options`.
240+
InitializeDefaultFlags();
244241
ProcessFlags();
245242
ApplyFlags();
246243
});

compiler-rt/test/asan/TestCases/Windows/alloc_dealloc_mismatch.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %clangxx_asan -O0 %s -o %t -DUSER_FUNCTION
66
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-MISMATCH
77

8+
// It is expected that ASAN_OPTS will override the value set through the user function.
9+
// RUN: %env_asan_opts=alloc_dealloc_mismatch=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUCCESS
10+
811
#if USER_FUNCTION
912
// It's important to test the `alloc_dealloc_mismatch` flag set through the user function because, on Windows,
1013
// flags configured through the user-defined function `__asan_default_options` are not always be honored.

0 commit comments

Comments
 (0)