forked from OSchip/llvm-project
[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. llvm-svn: 215949
This commit is contained in:
parent
57d9ab648c
commit
2e39027931
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -36,7 +36,7 @@ bool DisabledInThisThread() { return disable_counter > 0; }
|
|||
|
||||
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
|
||||
|
|
|
@ -131,7 +131,7 @@ enum IgnoreObjectResult {
|
|||
};
|
||||
|
||||
// Functions called from the parent tool.
|
||||
void InitCommonLsan();
|
||||
void InitCommonLsan(bool standalone);
|
||||
void DoLeakCheck();
|
||||
bool DisabledInThisThread();
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue