[compiler-rt] r215949 - [LSan] Parse common flags from LSAN_OPTIONS even if LSan is combined with
Sergey Matveev
earthdok at google.com
Mon Sep 8 08:34:38 PDT 2014
ping?
On Fri, Aug 22, 2014 at 6:26 PM, Sergey Matveev <earthdok at google.com> wrote:
> I'm not sure I like this. This means that we can initialize ASan using the
> flag values from ASAN_OPTIONS, then override them with the values from
> LSAN_OPTIONS and keep running with the new values. I'm pretty sure some of
> our code assumes that the flags don't change after initialization.
>
>
> On Tue, Aug 19, 2014 at 3:39 AM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
>
>> Author: samsonov
>> Date: Mon Aug 18 18:39:47 2014
>> New Revision: 215949
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=215949&view=rev
>> Log:
>> [LSan] Parse common flags from LSAN_OPTIONS even if LSan is combined with
>> another sanitizer.
>>
>> A user may run both LSan and LSan+ASan. It is weird to pass path to leak
>> suppression file (or other common sanitizer flags, like "verbosity") in
>> "LSAN_OPTIONS" in the first case and in "ASAN_OPTIONS" in the second case.
>>
>>
>> Modified:
>> compiler-rt/trunk/lib/asan/asan_rtl.cc
>> compiler-rt/trunk/lib/lsan/lsan.cc
>> compiler-rt/trunk/lib/lsan/lsan_common.cc
>> compiler-rt/trunk/lib/lsan/lsan_common.h
>> compiler-rt/trunk/test/lsan/TestCases/ignore_object.cc
>> compiler-rt/trunk/test/lsan/TestCases/ignore_object_errors.cc
>> compiler-rt/trunk/test/lsan/TestCases/leak_check_at_exit.cc
>> compiler-rt/trunk/test/lsan/TestCases/print_suppressions.cc
>> compiler-rt/trunk/test/lsan/TestCases/suppressions_file.cc
>>
>> Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
>> +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Mon Aug 18 18:39:47 2014
>> @@ -680,7 +680,7 @@ static void AsanInitInternal() {
>> SanitizerInitializeUnwinder();
>>
>> #if CAN_SANITIZE_LEAKS
>> - __lsan::InitCommonLsan();
>> + __lsan::InitCommonLsan(false);
>> if (common_flags()->detect_leaks &&
>> common_flags()->leak_check_at_exit) {
>> Atexit(__lsan::DoLeakCheck);
>> }
>>
>> Modified: compiler-rt/trunk/lib/lsan/lsan.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/lsan/lsan.cc (original)
>> +++ compiler-rt/trunk/lib/lsan/lsan.cc Mon Aug 18 18:39:47 2014
>> @@ -25,16 +25,6 @@ bool lsan_init_is_running;
>>
>> namespace __lsan {
>>
>> -static void InitializeCommonFlags() {
>> - CommonFlags *cf = common_flags();
>> - SetCommonFlagsDefaults(cf);
>> - cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
>> - cf->malloc_context_size = 30;
>> - cf->detect_leaks = true;
>> -
>> - ParseCommonFlagsFromString(cf, GetEnv("LSAN_OPTIONS"));
>> -}
>> -
>> ///// Interface to the common LSan module. /////
>> bool WordIsPoisoned(uptr addr) {
>> return false;
>> @@ -50,7 +40,7 @@ extern "C" void __lsan_init() {
>> return;
>> lsan_init_is_running = true;
>> SanitizerToolName = "LeakSanitizer";
>> - InitializeCommonFlags();
>> + InitCommonLsan(true);
>> InitializeAllocator();
>> InitTlsSize();
>> InitializeInterceptors();
>> @@ -62,7 +52,6 @@ extern "C" void __lsan_init() {
>>
>> Symbolizer::GetOrInit();
>>
>> - InitCommonLsan();
>> if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
>> Atexit(DoLeakCheck);
>> lsan_inited = true;
>>
>> Modified: compiler-rt/trunk/lib/lsan/lsan_common.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/lsan/lsan_common.cc (original)
>> +++ compiler-rt/trunk/lib/lsan/lsan_common.cc Mon Aug 18 18:39:47 2014
>> @@ -36,7 +36,7 @@ bool DisabledInThisThread() { return dis
>>
>> Flags lsan_flags;
>>
>> -static void InitializeFlags() {
>> +static void InitializeFlags(bool standalone) {
>> Flags *f = flags();
>> // Default values.
>> f->report_objects = false;
>> @@ -71,6 +71,17 @@ static void InitializeFlags() {
>> ParseFlag(options, &f->log_threads, "log_threads", "");
>> ParseFlag(options, &f->exitcode, "exitcode", "");
>> }
>> +
>> + // Set defaults for common flags (only in standalone mode) and parse
>> + // them from LSAN_OPTIONS.
>> + CommonFlags *cf = common_flags();
>> + if (standalone) {
>> + SetCommonFlagsDefaults(cf);
>> + cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
>> + cf->malloc_context_size = 30;
>> + cf->detect_leaks = true;
>> + }
>> + ParseCommonFlagsFromString(cf, options);
>> }
>>
>> #define LOG_POINTERS(...) \
>> @@ -106,8 +117,8 @@ void InitializeRootRegions() {
>> root_regions = new(placeholder) InternalMmapVector<RootRegion>(1);
>> }
>>
>> -void InitCommonLsan() {
>> - InitializeFlags();
>> +void InitCommonLsan(bool standalone) {
>> + InitializeFlags(standalone);
>> InitializeRootRegions();
>> if (common_flags()->detect_leaks) {
>> // Initialization which can fail or print warnings should only be
>> done if
>>
>> Modified: compiler-rt/trunk/lib/lsan/lsan_common.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_common.h?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/lsan/lsan_common.h (original)
>> +++ compiler-rt/trunk/lib/lsan/lsan_common.h Mon Aug 18 18:39:47 2014
>> @@ -131,7 +131,7 @@ enum IgnoreObjectResult {
>> };
>>
>> // Functions called from the parent tool.
>> -void InitCommonLsan();
>> +void InitCommonLsan(bool standalone);
>> void DoLeakCheck();
>> bool DisabledInThisThread();
>>
>>
>> Modified: compiler-rt/trunk/test/lsan/TestCases/ignore_object.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/ignore_object.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/lsan/TestCases/ignore_object.cc (original)
>> +++ compiler-rt/trunk/test/lsan/TestCases/ignore_object.cc Mon Aug 18
>> 18:39:47 2014
>> @@ -1,7 +1,7 @@
>> // Test for __lsan_ignore_object().
>> // RUN:
>> LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0:verbosity=2"
>> // RUN: %clangxx_lsan %s -o %t
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE ASAN_OPTIONS=$ASAN_OPTIONS:"verbosity=2"
>> not %run %t 2>&1 | FileCheck %s
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> Modified: compiler-rt/trunk/test/lsan/TestCases/ignore_object_errors.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/ignore_object_errors.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/lsan/TestCases/ignore_object_errors.cc
>> (original)
>> +++ compiler-rt/trunk/test/lsan/TestCases/ignore_object_errors.cc Mon Aug
>> 18 18:39:47 2014
>> @@ -1,7 +1,7 @@
>> // Test for incorrect use of __lsan_ignore_object().
>> // RUN: LSAN_BASE="verbosity=2"
>> // RUN: %clangxx_lsan %s -o %t
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE ASAN_OPTIONS=$ASAN_OPTIONS:verbosity=2
>> %run %t 2>&1 | FileCheck %s
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE %run %t 2>&1 | FileCheck %s
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> Modified: compiler-rt/trunk/test/lsan/TestCases/leak_check_at_exit.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/leak_check_at_exit.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/lsan/TestCases/leak_check_at_exit.cc (original)
>> +++ compiler-rt/trunk/test/lsan/TestCases/leak_check_at_exit.cc Mon Aug
>> 18 18:39:47 2014
>> @@ -3,8 +3,8 @@
>> // RUN: %clangxx_lsan %s -o %t
>> // RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s
>> --check-prefix=CHECK-do
>> // RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
>> --check-prefix=CHECK-do
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0"
>> ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" not %run %t foo 2>&1 |
>> FileCheck %s --check-prefix=CHECK-do
>> -// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0"
>> ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" %run %t 2>&1 | FileCheck
>> %s --check-prefix=CHECK-dont
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" not %run %t foo
>> 2>&1 | FileCheck %s --check-prefix=CHECK-do
>> +// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0" %run %t 2>&1 |
>> FileCheck %s --check-prefix=CHECK-dont
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> Modified: compiler-rt/trunk/test/lsan/TestCases/print_suppressions.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/print_suppressions.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/lsan/TestCases/print_suppressions.cc (original)
>> +++ compiler-rt/trunk/test/lsan/TestCases/print_suppressions.cc Mon Aug
>> 18 18:39:47 2014
>> @@ -2,9 +2,9 @@
>> // matched. Default is print_suppressions=true.
>> // RUN: LSAN_BASE="use_registers=0:use_stacks=0"
>> // RUN: %clangxx_lsan %s -o %t
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0
>> ASAN_OPTIONS=$ASAN_OPTIONS:print_suppressions=0 %run %t 2>&1 | FileCheck %s
>> --check-prefix=CHECK-dont-print
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %run %t 2>&1 |
>> FileCheck %s --check-prefix=CHECK-dont-print
>> // RUN: LSAN_OPTIONS=$LSAN_BASE %run %t 2>&1 | FileCheck %s
>> --check-prefix=CHECK-dont-print
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0
>> ASAN_OPTIONS=$ASAN_OPTIONS:print_suppressions=0 %run %t foo 2>&1 |
>> FileCheck %s --check-prefix=CHECK-dont-print
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %run %t foo 2>&1 |
>> FileCheck %s --check-prefix=CHECK-dont-print
>> // RUN: LSAN_OPTIONS=$LSAN_BASE %run %t foo 2>&1 | FileCheck %s
>> --check-prefix=CHECK-print
>>
>> #include <stdio.h>
>>
>> Modified: compiler-rt/trunk/test/lsan/TestCases/suppressions_file.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/suppressions_file.cc?rev=215949&r1=215948&r2=215949&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/test/lsan/TestCases/suppressions_file.cc (original)
>> +++ compiler-rt/trunk/test/lsan/TestCases/suppressions_file.cc Mon Aug 18
>> 18:39:47 2014
>> @@ -2,10 +2,10 @@
>> // RUN: %clangxx_lsan %s -o %t
>>
>> // RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp1
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1
>> ASAN_OPTIONS=$ASAN_OPTIONS:suppressions=%t.supp1 not %run %t 2>&1 |
>> FileCheck %s
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 not %run %t 2>&1 |
>> FileCheck %s
>>
>> // RUN: echo "leak:%t" > %t.supp2
>> -// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false
>> ASAN_OPTIONS=$ASAN_OPTIONS:suppressions="%t.supp2" %run %t
>> +// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false
>> %run %t
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140908/9892dd09/attachment.html>
More information about the llvm-commits
mailing list