forked from OSchip/llvm-project
[msan] Change track-origins default mode from 1 to 2.
Change -fsanitize-memory-track-origins to be equivalent to -fsanitize-memory-track-origins=2. Track-origins=2 provides a lot more detailed reports at the cost of some additional slowdown (ranging from none to, sometimes, 3x; ~3% average on SPEC2006). llvm-svn: 230644
This commit is contained in:
parent
0b57fc3147
commit
6e09bca0ef
|
@ -110,30 +110,10 @@ Origin Tracking
|
|||
|
||||
MemorySanitizer can track origins of unitialized values, similar to
|
||||
Valgrind's --track-origins option. This feature is enabled by
|
||||
``-fsanitize-memory-track-origins`` Clang option. With the code from
|
||||
``-fsanitize-memory-track-origins=2`` (or simply
|
||||
``-fsanitize-memory-track-origins``) Clang option. With the code from
|
||||
the example above,
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
% clang -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O2 umr.cc
|
||||
% ./a.out
|
||||
WARNING: MemorySanitizer: use-of-uninitialized-value
|
||||
#0 0x7f7893912f0b in main umr2.cc:6
|
||||
#1 0x7f789249b76c in __libc_start_main libc-start.c:226
|
||||
|
||||
Uninitialized value was created by a heap allocation
|
||||
#0 0x7f7893901cbd in operator new[](unsigned long) msan_new_delete.cc:44
|
||||
#1 0x7f7893912e06 in main umr2.cc:4
|
||||
|
||||
Origin tracking has proved to be very useful for debugging MemorySanitizer
|
||||
reports. It slows down program execution by a factor of 1.5x-2x on top
|
||||
of the usual MemorySanitizer slowdown.
|
||||
|
||||
MemorySanitizer can provide even more information with
|
||||
``-fsanitize-memory-track-origins=2`` flag. In this mode reports
|
||||
include information about intermediate stores the uninitialized value went
|
||||
through.
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
% cat umr2.cc
|
||||
|
@ -162,6 +142,15 @@ through.
|
|||
#0 0x7f7893901cbd in operator new[](unsigned long) msan_new_delete.cc:44
|
||||
#1 0x7f7893912e06 in main umr2.cc:4
|
||||
|
||||
By default, MemorySanitizer collects both allocation points and all
|
||||
intermediate stores the uninitialized value went through. Origin
|
||||
tracking has proved to be very useful for debugging MemorySanitizer
|
||||
reports. It slows down program execution by a factor of 1.5x-2x on top
|
||||
of the usual MemorySanitizer slowdown.
|
||||
|
||||
Clang option ``-fsanitize-memory-track-origins=1`` enabled a slightly
|
||||
faster mode when MemorySanitizer collects only allocation points but
|
||||
not intermediate stores.
|
||||
|
||||
Handling external code
|
||||
============================
|
||||
|
|
|
@ -1030,10 +1030,11 @@ are listed below.
|
|||
uninitialized bits came from. Slows down execution by additional
|
||||
1.5x-2x.
|
||||
|
||||
Possible values for level are 0 (off), 1 (default), 2. Level 2 adds more
|
||||
sections to MemorySanitizer reports describing the order of memory stores
|
||||
the uninitialized value went through. Beware, this mode may use a lot of
|
||||
extra memory.
|
||||
Possible values for level are 0 (off), 1, 2 (default). Level 2
|
||||
adds more sections to MemorySanitizer reports describing the
|
||||
order of memory stores the uninitialized value went
|
||||
through. This mode may use extra memory in programs that copy
|
||||
uninitialized memory a lot.
|
||||
|
||||
Extra features of UndefinedBehaviorSanitizer:
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
|||
options::OPT_fsanitize_memory_track_origins,
|
||||
options::OPT_fno_sanitize_memory_track_origins)) {
|
||||
if (A->getOption().matches(options::OPT_fsanitize_memory_track_origins)) {
|
||||
MsanTrackOrigins = 1;
|
||||
MsanTrackOrigins = 2;
|
||||
} else if (A->getOption().matches(
|
||||
options::OPT_fno_sanitize_memory_track_origins)) {
|
||||
MsanTrackOrigins = 0;
|
||||
|
|
|
@ -66,11 +66,13 @@
|
|||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -pie %s -### 2>&1
|
||||
// OK
|
||||
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-1
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-2
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=1 -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-1
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-1
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fno-sanitize-memory-track-origins -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-1
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=0 -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-1
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=1 -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-2
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-2
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fno-sanitize-memory-track-origins -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-2
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=0 -fsanitize-memory-track-origins=1 -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-1
|
||||
// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins=0 -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACK-ORIGINS-2
|
||||
|
||||
// CHECK-TRACK-ORIGINS-1: -fsanitize-memory-track-origins=1
|
||||
|
||||
|
|
Loading…
Reference in New Issue